home-assistant / iOS

:iphone: Home Assistant for Apple platforms
https://companion.home-assistant.io
Other
1.58k stars 307 forks source link

The actionable notification doesn't return `tag` of the message #1666

Open t0ny-peng opened 3 years ago

t0ny-peng commented 3 years ago

iOS device model, version and app version

Model Name: iPhone 12 Plug Software Version: 14.5 App version: 2021.158

Home Assistant Core Version

2021.6.5 Describe the bug

I'm following the example in vacation mode with Nodered. In the example, an actionable notification was sent to the phone with tag in the data field to filter out actions sent back by other notification and only handle the mobile_app_notification_action event that is meant for this automation.

In the example it looks like the mobile_app_notification_action event should come back with the tag field, but that's not the case from debugging output. image

To Reproduce

A minimal reproducible example would be this:

Service call to send the notification

service: notify.mobile_app_jojo
data:
  message: "The front door is unlocked!"
  data:
    # replace any existing front_door_lock notifications
    tag: front_door_lock
    actions:
      - action: "ALARM" # The key you are sending for the event
        title: "Sound Alarm" # The button title
      - action: "URI" # Must be set to URI if you plan to use a URI
        title: "Open Url"

Event data captured:

{
    "event_type": "mobile_app_notification_action",
    "data": {
        "action": "ALARM"
    },
    "origin": "REMOTE",
    "time_fired": "2021-06-16T06:24:23.657627+00:00",
    "context": {
        "id": "03c50fd31e0d99f326de93837980c876",
        "parent_id": null,
        "user_id": "462b3fce20694a84b7619028d2d42b12"
    }
}

Expected behavior There should be a tag field in the event to tell which notification the reply is from.

Screenshots

Additional context

zacwest commented 3 years ago

I cannot find any documentation that says tag will get sent back, nor does it look like the Android app does so. I'm not sure where this came from, can you clarify what you're looking for?

t0ny-peng commented 3 years ago

@zacwest Thanks for the reply. I was using the official example from the node-red-contrib-home-assistant-websocket documentation(link).

In the example, the notify service is called with a tag(thus the message could be updated or so). image

Then when the user click the button, a mobile_app_notification_action event is fired. The example flow compares the tag field from the event payload with the previously globally set tag to check if the message belong to this flowchart. That's how I get the expectation that the tag will be returned. image

The example was developed by @zachowj. Not sure if you guys know each other😂

zacwest commented 3 years ago

I busted out my Android phone, and you're right, it does come through:

{
    "event_type": "mobile_app_notification_action",
    "data": {
        "tag": "TEST_TAG",
        "message": "hey",
        "action_1_title": "HEY",
        "action_1_key": "HEY",
        "action": "HEY",
        "device_id": "e30882b6e53743fd"
    },
    "origin": "REMOTE",
    "time_fired": "2021-06-30T03:18:24.422064+00:00",
    "context": {
        "id": "4f548571f045fd4138c40cf3be9fc6da",
        "parent_id": null,
        "user_id": "76ce52a813c44fdf80ee36f926d62328"
    }
}

I believe this is an accident, but I'll see if the Android devs want to commit to continuing to support it. If so, I can make the iOS app send tag as well.

t0ny-peng commented 3 years ago

@zacwest Thanks for the experiment! It looks like a great feature(and doesn't require too much development work). So I really hope it could be kept

richardtjena commented 2 years ago

@zacwest Any news regarding this?

Would be much appreciated if this was added so that both companion apps delivered the same responses back to Home Assistant.

IzeQube commented 2 years ago

Yes, this would be great.

WhoTheHeck commented 3 weeks ago

Was this solved for some time but isnt anymore? I could swear I had an automation a few months ago that would trigger on:

  trigger:
    - platform: event
      event_type: mobile_app_notification_action
      event_data:
        tag: "my_tag"

Now I no longer receive the tag as a payload and need to trigger on all the actions that the automation handles.