Activating automation based on Android notification

hi all.
I’m following this doco: Sensors | Home Assistant Companion Docs (home-assistant.io)
and I’m trying to use android.text or android.subText or android.title to activate an automation.

The automation is currently only testing if HA can read these notifications. So when the 3rd party app sends notification, HA should notify me as well.

Though I’ve configured HA companion app sensor to allow reading of notifications, the traces shows no activity.

alias: Reolink notification
description: ""
trigger:
  - platform: state
    entity_id:
      - sensor.gil_galaxy_s23_last_notification
    attribute: android.subText
    to: Camera Alert
condition: []
action:
  - device_id: 473a09479b001acfd5c5bc87923bfcf5
    domain: mobile_app
    type: notify
    message: you got notification from reolink
mode: single

What am I missing here?

It seems that there is no Action defined like
service:notify.xxxx

Even when using the service it doesn’t work.

alias: Reolink notification
description: ""
trigger:
  - platform: state
    entity_id:
      - sensor.gil_galaxy_s23_last_notification
    attribute: android.text
    to: Person is detected from Entrance cam.
condition: []
action:
  - device_id: 473a09479b001acfd5c5bc87923bfcf5
    domain: mobile_app
    type: notify
    message: you got notification from reolink
    title: HA Reolink
    enabled: false
  - service: notify.mobile_app_gil_galaxy_s23
    data:
      message: you got notification from reolink
      title: HA Reolink
mode: single

Remove the first 6 lines after action so that it looks like this and try again.

action:
  - service: notify.mobile_app_gil_galaxy_s23
    data:
      message: you got notification from reolink
      title: HA Reolink
mode: single

Also is the to text above correct?

Person is detected from Entrance cam.

It has to be 100% correct, otherwise the trigger will not fire. Try setting the Text between double quote.

I’m getting an error message when I use the service instead of device.

The automation "Reolink notification" (automation.reolink_notification) has an action that calls an unknown service: notify.mobile_app_gil_galaxy_s23.

The text is 100% correct.

Please post your new code.

And check if your mobile ist configured in HA. Goto Developer Tools->Services and search for “notify.mobile”. Does you mobile phone show up? Post a screen shot.

Yes, it’s enabled:

Based on the companion app, it seems I need to use android.bigText so I’ll try that.

alias: Reolink notification
description: ""
trigger:
  - platform: state
    entity_id:
      - sensor.gil_galaxy_s23_last_notification
    attribute: android.bigText
    to: Person is detected from Entrance cam.
condition: []
action:
  - device_id: 473a09479b001acfd5c5bc87923bfcf5
    domain: mobile_app
    type: notify
    message: you got notification from reolink
    title: HA Reolink
    enabled: true
mode: single

First you need to use this action as I said above:

action:
  - service: notify.mobile_app_gil_galaxy_s23
    data:
      message: you got notification from reolink
      title: HA Reolink
mode: single

Second you need to check in Home Assistant not in the companion app. Verify if notify.mobile_app_gil_galaxy_s23 is in the list.

In HA, this is what I see:

Using the service call, I get this error from HA:
The automation "Reolink notification" (automation.reolink_notification) has an action that calls an unknown service: notify.mobile_app_gil_galaxy_s23.

That is why I reverted back to the original automation configuration I posted.

Please try to execute the service from the dev tools. Select your S23 and put in some test data and then execute it like this:

this worked:

I got the notification on the phone

Bingo. So that works. The question now is why you get an error calling the same service from within your automation. Try using double quotes for the text and make sure the indentations are exactly as shown.

action:
  - service: notify.mobile_app_gil_galaxy_s23
    data:
      message: "you got notification from reolink"
      title: "HA Reolink"

Still doesn’t work.

Traces shows No traces found

description: ""
trigger:
  - platform: state
    entity_id:
      - sensor.gil_galaxy_s23_last_notification
    attribute: android.title
    to: Camera Alert
condition: []
action:
  - service: notify.mobile_app_gil_galaxy_s23
    data:
      message: you got notification from reolink
      title: HA Reolink
mode: single

If there are no traces then your trigger does not work. I think you cannot trigger on the attribute of that sensor because it has none. Try this. Remove attribute: and to: lines. This should trigger on any state change.

trigger:
  - platform: state
    entity_id:
      - sensor.gil_galaxy_s23_last_notification

I tried it. The sensor.xxx_last_notification state is the Title Text of the notification. So I sent an email with title Test3 to my mobile which triggered the automation. For me this works.

- id: '20230914141356'
  alias: 'Mobile App Notification Test'
  initial_state: 'on'
  trigger:
  - platform: state
    entity_id: sensor.sm_s916b_last_notification
    to: "Test3"
  action:
    - service: notify.mobile_app_sm_s916b
      data_template:
        message: "Mobile App Notification received."

Would be nice if you could let me know if this now works for you.