Skip to content

Conversation

@timbms
Copy link
Contributor

@timbms timbms commented Aug 12, 2025

  • Enhances notification handling by introducing PushNotificationPayload a structured payload model
  • Improves UI display with icons
  • Refactors various notification-related components

timbms and others added 7 commits August 12, 2025 12:01
Used guard instead of throwing cancellation
Added proper weak self captures throughout

Signed-off-by: Tim Mueller-Seydlitz <[email protected]>
Signed-off-by: Tim Mueller-Seydlitz <[email protected]>
Comprehensive parsing of notifications
Improved error handling

Signed-off-by: Tim Mueller-Seydlitz <[email protected]>
Signed-off-by: Tim Mueller-Seydlitz <[email protected]>
Signed-off-by: Tim Mueller-Seydlitz <[email protected]>
@timbms timbms requested a review from Copilot August 14, 2025 12:56
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Enhances notification handling by introducing a structured payload model, improving UI display with icons, and refactoring various notification-related components.

  • Introduces PushNotificationPayload for structured notification data parsing
  • Adds notification icon display support and image fetching functionality
  • Updates notification models and API methods for better data handling

Reviewed Changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
openHAB/AppDelegate.swift Adds image fetching for notification icons and updates notification display logic
openHAB/NotificationsView.swift Updates UI state management and API method names
openHAB/OpenHABRootViewController.swift Fixes typo in comment
OpenHABCore/Sources/OpenHABCore/Model/PushNotificationPayload.swift New structured payload model for push notifications
OpenHABCore/Sources/OpenHABCore/Model/OpenHABNotification.swift Restructures notification model with expanded payload support
OpenHABCore/Sources/OpenHABCore/Util/HTTPClient.swift Renames method for consistency
OpenHABCore/Sources/OpenHABCore/Util/Endpoint.swift Adds default parameters to icon method
openHAB.xcodeproj/project.pbxproj Changes code signing configuration
fastlane/Fastfile Updates changelog format
CHANGELOG.md Adds recent change entries

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

timbms and others added 3 commits August 14, 2025 14:57
Signed-off-by: Tim Mueller-Seydlitz <[email protected]>
Signed-off-by: Tim Mueller-Seydlitz <[email protected]>
@timbms
Copy link
Contributor Author

timbms commented Aug 15, 2025

I overlooked NotificationService, maybe because it never worked so far for me.

@digitaldan
Copy link
Contributor

I overlooked NotificationService, maybe because it never worked so far for me.

Not sure i understand, push notifications in general don't work for you ?

@timbms
Copy link
Contributor Author

timbms commented Aug 16, 2025

Push notification work for me but the attached image is never displayed to me

@digitaldan
Copy link
Contributor

but the attached image is never displayed to me

Is the image a openHAB image item or are you referencing a URL? It works for me consistently, would like to track down why its not working for you. FYI the "icon" option in the cloud actions does not work on iOS, maybe it did at one point long ago before i inherited it, but there is not a way to show an icon in an actual native iOS notification short of attaching it as a image which doesn't really make sense in practice.

@timbms
Copy link
Contributor Author

timbms commented Aug 17, 2025

Can you please share an example call from a openhab rule where you send a notification

@digitaldan
Copy link
Contributor

Here's a notification when someone rings my front gate.

    actions.notificationBuilder("Someone is at the Front Gate")
    .addUserId(email)
    .withTitle('Front Gate')
    .withTag('front-gate-activity')
    .withReferenceId('front-gate-activity')
    .withOnClickAction('ui:popup:widget:gate_control')
    .withMediaAttachmentUrl('https://www.xxx.com/xxx/front-gate')
    .addActionButton('Open Gate','command:GDSDrivewayGateSwitch:ON')
    .addActionButton('Answer Call','ui:popup:widget:gate_control_auto')
    .send();

where https://www.xxx.com/xxx/front-gate is a link to a jpg snapshot of my camera. I run wireguard on my phone, so i always have access to my internal network, otherwise i would have to expose that camera to the outside world OR use a openHAB image item (though myopenHAB) which also works nicely.

I was actually just looking at changing the core HTTP rule actions to include an option to download and set an image to an item to make this easier for people, that would probably make this feature more accessible.

@digitaldan
Copy link
Contributor

@timbms if you are running 5.0.x nightlies, i added a new HTTP rule action to help with using images in notifications, you can grab a local image and set it as the state of an Item, then use that in the notification. This will work through myopenHAB as well a local, also has the advantage of capturing the image as the even happens, where a notification could be several seconds later and if hitting the camera directly, could miss the event in the image (which is why i will start using this)

These are taken from the cloud binding README

Rules DSL

rule "Motion Detected Notification"
when
  Item Apartment_MotionSensor changed to ON
then
  setImage("Apartment_Camera_Snapshot", "http://camera.local/camera-snapshot.jpg");
  sendBroadcastNotification("Motion detected in the apartment!", "motion", "Motion Tag",
                                    "Motion Detected", "motion-id-1234", null, "item:Apartment_Camera_Snapshot",
                                    "Turn on the light=command:Apartment_Light:ON", null, null)
end

Javascript Rules

rules.when().item('Apartment_MotionSensor').changed().to('ON').then(() => {
  actions.HTTP.setImage("Apartment_Camera_Snapshot", "http://camera.local/camera-snapshot.jpg");
  actions.notificationBuilder('Motion detected in the apartment!')
    .withIcon('motion')
    .withTag('Motion Tag')
    .withTitle('Motion Detected')
    .withReferenceId('motion-id-1234')
    .withMediaAttachment('item:Apartment_Camera_Snapshot')
    .addActionButton('Turn on the light', 'command:Apartment_Light:ON')
    .send();
}).build('Motion Detected Notification');

Ruby Rules

rule "Motion Detected Notification" do
  changed Apartment_MotionSensor, to: ON
  run do
    HTTP.setImage("Apartment_Camera_Snapshot", "http://camera.local/camera-snapshot.jpg");
    Notification.send "Motion detected in the apartment!",
                      icon: "motion",
                      tag: "Motion Tag",
                      title: "Motion Detected",
                      id: "motion-id-1234"
                      attachment: "item:Apartment_Camera_Snapshot",
                      buttons: { "Turn on the light" => "command:Apartment_Light:ON" }
  end
end

@timbms
Copy link
Contributor Author

timbms commented Aug 27, 2025

Cool feature @digitaldan

@digitaldan
Copy link
Contributor

Hey @timbms i'm back from a trip and back working on openHAB, do you need anything from me on this PR?

@timbms
Copy link
Contributor Author

timbms commented Sep 4, 2025

Hi @digitaldan good you are back. I was also off in remote Swiss mountains.
Ideally you could address some feedback received from the TestFlight users. There is for instance a user reporting images not appearing in notifications https://appstoreconnect.apple.com/m/teams/69a6de8f-0003-47e3-e053-5b8c7c11a4d1/apps/6505005945/testflight/screenshots/AMdc0bIAIcdgHuTdLDvEo1E

@digitaldan
Copy link
Contributor

There is for instance a user reporting images not appearing in notifications

The fix on the other notification PR that just got merged will address this.

Hope you had a good holiday! My question was on this PR, are you waiting for a review, or is there more work to do?

options.append(contentsOf: extraOptions)

// Async Kingfisher call → gives you RetrieveImageResult with a UIImage.
let result = try await KingfisherManager.shared.retrieveImage(with: url, options: options)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this will work with setups with authentication, client certs or myopenhab ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants