How to use payload from ios.notification_action_fired

Hi, I am loving the new app!

I have a little problem though. I currently have actionable notifications working and I’m loving it. I have created a group of iphones that each receive a snapshot taken froma camera above my front door when the doorbell is pressed. the actionable notification comes through showing the picture and a action button asks if you would like to view the live feed from the camera. if you press the action button a dynamic notification is sent containing the camera feed. the thing is all devices in the group receive the dynamic notification not just the device that requested it. I have tried to use the device ID from the ios_notication_action_fired event payload but it doesnt seem to work.

this works but sends to all devices in group:

  • alias: Wesley wants the stream
    trigger:
    • platform: event
      event_type: ios.notification_action_fired
      event_data:
      actionName: SHOW_FEED
      action:
      send to all because I don’t know who fired the event

this doesn’t work and breaks the automation:

  • alias: Wesley wants the stream
    trigger:
    • platform: event
      event_type: ios.notification_action_fired
      event_data:
      sourceDeviceID: wesleys_iphone
      action:
      send wesley the feed because I know he pressed the button

I think I’ve sort of solved the problem. I went through the log and found “sourceDeviceName=wesley’s iphone” in the ios_notification_action_fired event. I couldn’t get that to work, even tried with and without quotation marks around wesley’s iphone. After that entry was “sourceDevicePermanentID=98357BA9-B763-4D96-BEBD-63486A87FB4F” and using that works! The downside is that I think the only way to find this ID number is from the log which is a little bit boring.

Each device will need its own automation containing its ID to receive the live feed dynamic notification. Does someone know of a way to script if else type automations? I think thats probably not possible right now.

Here’s the working automation:

  - alias: Wesley wants the stream
trigger:
  - platform: event
    event_type: ios.notification_action_fired
    event_data:
      # actionName: SHOW_FEED
      # sourceDeviceName: "wesley's iphone"
      sourceDevicePermanentID: 98357BA9-B763-4D96-BEBD-63486A87FB4F
action:
  - service: notify.ios_wesleys_iphone
    data:
      message: Door Cam Live
      data:
        push:
          category: camera
        entity_id: camera.door_cam_live

Another thing has occurred to me whilst writing this and that is that this automation will fire when any actionable button is pressed by the device with the corresponding ID. This works for me, for now, as I only have one action. I see this solution failing me as the complexity of my ios notifications increases!

1 Like

View the entire code here: https://hastebin.com/otubinavik.http

1 Like

Are you getting a notification with a still pic and then you have a button to send yourself another push with the live feed?

I’m trying to accomplish getting the live feed in the first notification and have actions like “close garage door”. I’ve tried practically every combination but can’t seem to get a camera along with actionable notifications in the same push. Ideas?

Have you read the whole code I am using? It sounds like you would just have to rearrange it slightly to achieve what you want. If you’ve had a go and it doesn’t work then maybe something funny is going on. I’ll have a little play with it when I get home to see if the live feed can have an action button attached.

Yes I read your code at the link you posted. However, I think it’s much different as you only have one category per push notification. The docs say you can add actionable notifications onto the video stream in a single notification (Implies you can combine 2 separate categories to a notification) but there’s no example of how to combine categories together. I’ve tried all sorts of combos but either I get nothing but the message or just the message and camera feed but the actionable part never appears. If you do figure it out, I’d love to know!! :slight_smile:

I’m going to give up. Here’s the combo’s I’ve tried. Actually, I’ve tried more but these at least compile pthe YAML properly. The documentation is not clear at all on how to combine dynamic content such as video with actionable notifications. I didn’t try adding the camera to the ios part because it doesn’t seem logical there. Any ideas?

ios:
  push:
    categories:
      - name: garagedoor
        identifier: 'GARAGEDOOR'
        actions:
          - identifier: 'CLOSE_GARAGE_DOOR'
            title: 'Close Garage'
            activationMode: 'background'
            authenticationRequired: yes
            destructive: yes
            behavior: 'default'

my automations attempts:

  - alias: 'Test'
    trigger:
      platform: state
      entity_id: input_boolean.test
      to: 'on'
    action:
      - service: notify.ios_jeremys_iphone
        data:
          message: "Garage Door is Open"
          data:
            push:
              sound: "US-EN-Alexa-Garage-Door-Opened.wav"
              category: camera
            entity_id: camera.garage
            action_data: 
              category: "GARAGEDOOR"

  - alias: 'Test_2'
    trigger:
      platform: state
      entity_id: input_boolean.test_2
      to: 'on'
    action:
      - service: notify.ios_jeremys_iphone
        data:
          message: "Garage Door is Open"
          data:
            push:
              sound: "US-EN-Alexa-Garage-Door-Opened.wav"
              category: camera
            action_data:
              my_custom_data: "GARAGEDOOR"
            entity_id: camera.garage

  - alias: 'Test_3'
    trigger:
      platform: state
      entity_id: input_boolean.test_3
      to: 'on'
    action:
      - service: notify.ios_jeremys_iphone
        data:
          message: "Garage Door is Open"
          data:
            push:
              sound: "US-EN-Alexa-Garage-Door-Opened.wav"
              category: camera
              category: "GARAGEDOOR"
            entity_id: camera.garage

  - alias: 'Test_4'
    trigger:
      platform: state
      entity_id: input_boolean.test_2
      to: 'on'
    action:
      - service: notify.ios_jeremys_iphone
        data:
          message: "Garage Door is Open"
          data:
            push:
              sound: "US-EN-Alexa-Garage-Door-Opened.wav"
              category: camera
            action_data:
              my_custom_data:
                category: "GARAGEDOOR"
            entity_id: camera.garage

  - alias: 'Test_5'
    trigger:
      platform: state
      entity_id: input_boolean.test_3
      to: 'on'
    action:
      - service: notify.ios_jeremys_iphone
        data:
          message: "Garage Door is Open"
          data:
            push:
              sound: "US-EN-Alexa-Garage-Door-Opened.wav"
              category: camera
            entity_id: camera.garage
            action_data:
              my_custom_data:
                category: "GARAGEDOOR"

  - alias: 'Test_6'
    trigger:
      platform: state
      entity_id: input_boolean.test_3
      to: 'on'
    action:
      - service: notify.ios_jeremys_iphone
        data:
          message: "Garage Door is Open"
          data:
            push:
              sound: "US-EN-Alexa-Garage-Door-Opened.wav"
              category: camera
            entity_id: camera.garage
            action_data:
              my_custom_data: "GARAGEDOOR"

  - alias: 'Test_7'
    trigger:
      platform: state
      entity_id: input_boolean.test
      to: 'on'
    action:
      - service: notify.ios_jeremys_iphone
        data:
          message: "Garage Door is Open"
          data:
            push:
              sound: "US-EN-Alexa-Garage-Door-Opened.wav"
              category: camera
            entity_id: camera.garage
            action_data: "GARAGEDOOR"
  - alias: 'Test_8'
    trigger:
      platform: state
      entity_id: input_boolean.test
      to: 'on'
    action:
      - service: notify.ios_jeremys_iphone
        data:
          message: "Garage Door is Open"
          data:
            push:
              sound: "US-EN-Alexa-Garage-Door-Opened.wav"
              category: camera
              action_data: "GARAGEDOOR"
            entity_id: camera.garage


  - alias: 'Test_9'
    trigger:
      platform: state
      entity_id: input_boolean.test_2
      to: 'on'
    action:
      - service: notify.ios_jeremys_iphone
        data:
          message: "Garage Door is Open"
          data:
            push:
              sound: "US-EN-Alexa-Garage-Door-Opened.wav"
              category: camera
              custom_actions: "GARAGEDOOR"
            entity_id: camera.garage

  - alias: 'Test_10'
    trigger:
      platform: state
      entity_id: input_boolean.test_3
      to: 'on'
    action:
      - service: notify.ios_jeremys_iphone
        data:
          message: "Garage Door is Open"
          data:
            push:
              sound: "US-EN-Alexa-Garage-Door-Opened.wav"
              category: camera
            entity_id: camera.garage
            custom_actions: "GARAGEDOOR"
            
  - alias: 'Test_11'
    trigger:
      platform: state
      entity_id: input_boolean.test_3
      to: 'on'
    action:
      - service: notify.ios_jeremys_iphone
        data:
          message: "Garage Door is Open"
          data:
            push:
              sound: "US-EN-Alexa-Garage-Door-Opened.wav"
              category: 
                - camera
                - "GARAGEDOOR"
            entity_id: camera.garage

  - alias: 'Test_12'
    trigger:
      platform: state
      entity_id: input_boolean.test_2
      to: 'on'
    action:
      - service: notify.ios_jeremys_iphone
        data:
          message: "Garage Door is Open"
          data:
            push:
              sound: "US-EN-Alexa-Garage-Door-Opened.wav"
              category: camera
            entity_id: camera.garage
            action_data:
              custom_actions: "GARAGEDOOR"

  - alias: 'Test_13'
    trigger:
      platform: state
      entity_id: input_boolean.test_3
      to: 'on'
    action:
      - service: notify.ios_jeremys_iphone
        data:
          message: "Garage Door is Open"
          data:
            push:
              sound: "US-EN-Alexa-Garage-Door-Opened.wav"
              category: camera
            entity_id: camera.garage
            action_data:
              category: "GARAGEDOOR"

I took the following blurb from the ‘Dynamic Content’ page to mean that your iOS push category identifer had to be either ‘map’ or ‘camera’. I tried this with map (I have no camrea feeds) and it only produced a map notificatino with no action buttons. With this logic it would also limit you to only having one set of actions for a camera or a map notification.

Combining with actionable notifications

As you can see the category key is used to tell the device what kind of content extension to use. You can use the same category identifiers in your own custom actions to add actions to the content extension.

Automation Entry (testing by triggering in the web UI)

- alias: "iOS Alert Test"
  initial_state: true
  trigger:
    platform: homeassistant
    event: start
  action:
    service: notify.all
    data:
      message: "Something happened at home!"
      data:
        push:
          badge: 1
          category: map
        action_data:
          latitude: "40.785091"
          longitude: "-73.968285"

Entry under ios:

push:
    categories:
      - name: Map
        identifier: 'map'
        actions:
          - identifier: 'SOUND_ALARM'
            title: 'Sound Alarm'
            activationMode: 'background'
            authenticationRequired: yes
            destructive: yes
            behavior: 'default'
          - identifier: 'SILENCE_ALARM'
            title: 'Silence Alarm'
            activationMode: 'background'
            authenticationRequired: yes
            destructive: yes
            behavior: 'default'

@robbiet480 :slight_smile: Are you able to clarify how to combine the two types of dynamic notificaitons with actions?

Yeah I get what you’re saying but i figured it wouldn’t be the way he programmed it because it would limit to one camera or map push. I’m sure it’s something to do with adding an extra category but there’s something we are obviously not getting. I guess we will just have to be patient and wait for @robbiet480

You have have seen already, but with the latest updates (0.54 and later) if you set your action identifier to ‘camera’ all lowercase, then you can get the actions with the camera image. unfortunately this overrides all camera notify so you will see them on all camera notifications.