iOS icon indicating copy to clipboard operation
iOS copied to clipboard

sourceDeviceName not being passed in Actionable Notifications

Open greg-nyc opened this issue 4 years ago • 5 comments

iOS device model, version and app version

Model Name: iPhone 11 Pro Max Software Version: 15.1 App version: 2021.12.1 (2021.327)

Home Assistant Core Version 2021.12.6

Describe the bug I'm no longer seeing sourceDeviceName being passed in Home Assistant's event bus when an actionable notification has been triggered on my iOS device. I rely on the device name to differentiate which user is responding to the actionable notification so the appropriate action is triggered.

To Reproduce Here's the notification script I use (updated per the migration documentation):

affresh_wm_notify:
  alias: Affresh Washing Machine Notify
  description: 'Affresh Washing Machine Notification Routine'
  sequence:
    - service: notify.group
      data:
        title: "Affresh Washing Machine"
        message: "It's time to clean the washing machine. Have you done a maintenance cycle?"
        data:
          actions:
            - action: 'AFFRESH_WM_CLEANED'
              title: 'Done'
            - action: 'AFFRESH_WM_SNOOZE_15M'
              title: 'Remind me in 15 min'
            - action: 'AFFRESH_WM_SNOOZE_30M'
              title: 'Remind me in 30 min'
            - action: 'AFFRESH_WM_SNOOZE_1H'
              title: 'Remind me in 1 hour'
            - action: 'AFFRESH_WM_SNOOZE_2H'
              title: 'Remind me in 2 hours'
            - action: 'AFFRESH_WM_SNOOZE_24H'
              title: 'Remind me tomorrow'
          tag: "affresh_wm"

When triggered, this script produces the expected actionable notification. But when selecting an option, the event bus for mobile_app_notification_action looks like this:

{
    "event_type": "mobile_app_notification_action",
    "data": {
        "action": "AFFRESH_WM_SNOOZE_15M"
    },
    "origin": "REMOTE",
    "time_fired": "2021-12-29T01:10:17.072375+00:00",
    "context": {
        "id": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
        "parent_id": null,
        "user_id": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
    }
}

That means this automation is no longer triggered:

automation:
...
  trigger:
    - platform: event
      event_type: mobile_app_notification_action
      event_data:
        action: 'AFFRESH_WM_SNOOZE_15M'
        sourceDeviceName: 'Phone1'
...

This automation works if I remove the sourceDeviceName, but that doesn't solve the problem that no user-defined device name is being passed on the event bus.

Expected behavior A device identifier (preferably the user-defined device name) be passed in the data payload for mobile_app_notification_action.

greg-nyc avatar Dec 29 '21 01:12 greg-nyc

Can you confirm the last working version of the app that the above worked for. I am unsure sourceName has ever been provided in the payload from a notification action. It is however present in the payload from a regular action see here

TomBrien avatar Dec 29 '21 09:12 TomBrien

I've spent an hour or two trying to trace this back. It looks like the problem first appeared a few weeks ago when I started receiving an error that my actionable notifications needed to be migrated to the new format introduced 2021.5. I followed the migration instructions, which included changing the trigger event type from ios.notification_action_fired to mobile_app_notification_action.

The docs/notifications/actionable.md history proves this out. Pull request 630 deleted the payload information in the actionable notification documentation that included the sourceDeviceName . (See deleted line 433)

So all was working correctly when I selected an actionable notification and it fired under ios.notification_action_fired. But the same data is not being passed in the new, aligned action response.

This is why I think it's a bug and not a feature request. This was something that was working before the aligned actionable notifications that now no longer works.

greg-nyc avatar Jan 02 '22 17:01 greg-nyc

You are correct that this attribute is not included in the new mobile_app_notification_action event; we'll need to coordinate with Android to add it so we can keep them identical.

For the moment you can continue using ios.notification_action_fired - it will continue to be fired for the foreseeable future.

zacwest avatar Jan 02 '22 18:01 zacwest

Great. When I select an action from a triggered actionable notification, I see both mobile_app_notification_action and ios.notification_action_fired firing. I'll change my automation triggers back to looking for the events fired on ios.notification_action_fired. Just so we don't lose this reminder to coordinate and add user-defined device names to the events payload, do you want me to add it to discussions and close this issue out?

greg-nyc avatar Jan 02 '22 18:01 greg-nyc

I have noticed that the sourcedevicename attributes does not populate so I can no longer send notifications back to a particular device that fires an action

timknowlden avatar Feb 07 '22 20:02 timknowlden

I just found this issue while trying to figure out why the android app sends the device_id in mobile_app_notification_action event, but iOS app does not. I didn't know about the ios.notification_action_fired event, but it looks like sourceDeviceName isn't the only value that is no longer being sent in mobile_app_notification_action.

KocproZ avatar Dec 04 '22 12:12 KocproZ