Help with companion app automation

I have the following automation to notify me if garage door left opened for more that 7 minutes.
I do get the message in my android phone but when I push the notification button (in phone) to close the door won’t do do anything.
Does anybody know if it’s something wrong in the automation or in my phones setup?

Now that I am posting it I wonder if it would be better to use service: switch.toggle ?

`#Garage Door Opened for sometime
- alias: Notify apps when Garage Door open
  trigger:
    platform: state
    entity_id: binary_sensor.openclose_18
    from: 'off'
    to: 'on'
    for: '00:07:00'
  action:
    service: notify.mobile_app_sm_g955f
    data:
      message: The garage has been left open
      data:
        actions:
          - action: close_garage
            title: Close Garage Door
- alias: Close the garage when notification action is tapped
  trigger:
    platform: event
    event_type: mobile_app_notification_action
    event_data:
      action: close_garage
  action:
    service: switch.turn_off
    entity_id: switch.sonoff_100082f95b

Sorry, mine stopped working too but I don’t know when. Maybe there was a code change? If I monitor the events for mobile_app_notification_action in the developer console and I push the action button on the message, nothing happens. There seems to be a lot of chatter about this but no one with a solution. Here is one of my actions which used to work. Code not changed since deployed but HA upgraded to 0.111.4.

  - alias: Turn on foyer lamp when notification action is tapped
    trigger:
      platform: event
      event_type: mobile_app_notification_action
      event_data:
        action: foyer_on
    action:
      service: light.turn_on
      entity_id: light.foyer_front_light    

I’m not at home, so cant test right now. Did you try listening to all events and see whether the event name changed?

Thanks but not sure how to do that? What do I put in the event listener box for all events?

put a * in the listening box.

not sure what you are talking about :slight_smile:
but
in the events / event type
if I add “mobile_app_notification_action” and fire the event my garage door is opening?
is that right? I don’t think it should open it

I get nothing (in events monitor with *) when I push the notification but the app says “Failed to notify HA of picked option”. Maybe my image URL formatting is not right? It was working when I first set it up.

automation:
  - alias: Notify apps when the lamp if left on
    trigger:
      platform: state
      entity_id: light.family_room_lamp
      to: 'on'
      for: '0:01:00'
    action:
      service: notify.mobile_app_nokia_7_1_app
      data:
        message: "Lamp was left on for one minute"
        data:
          image: http://10.0.1.200:8123/local/lamp.jpg
          actions:
            - action: "lamp_off" # The key you are sending for the event
              title: "Turn off Lamp" # The button title

So yours is working, just opening instead of closing? If you’re using a Sonoff, won’t each toggle of the relay perform open then close etc.?

Would need to check the image url thing when I’m home. Did you try without the image only the actions?

I changed before a while to toggle, but I have to test it later or tomorrow when I got out of home.
I don’t really understand why the "mobile_app_notification_action”
toggles my garage door though when I just fire the event.

in the automation we have to point the service we want
eg

action:
    service: switch.toggle
    entity_id: switch.sonoff_100082f95b

how the "mobile_app_notification_action” event knows what it should do?

Probably I am missing something :shushing_face: ?

Nope, does not work without the image either. Anyone see anything wrong below?

automation:
  - alias: Notify apps when the lamp if left on
    trigger:
      platform: state
      entity_id: light.family_room_lamp
      to: 'on'
      for: '0:01:00'
    action:
      service: notify.mobile_app_nokia_7_1_app
      data:
        message: "Lamp was left on for one minute"
        data:
          # image: http://10.0.1.200:8123/local/lamp.jpg
          actions:
            - action: "lamp_off" # The key you are sending for the event
              title: "Turn off Lamp" # The button title

  - alias: Turn off lamp when notification action is tapped
    trigger:
      platform: event
      event_type: mobile_app_notification_action
      event_data:
        action: lamp_off
    action:
      service: light.turn_off
      entity_id: light.family_room_lamp

When you wrote the automation, you defined an action (above) called close_garage and this is being used as a reference to invoke your garage door toggle in the secondary automation where again close_garage is defined.

What is confusing me is the following. Lets assume that your automation works and I add it to my HA.

- alias: Turn off lamp when notification action is tapped
    trigger:
      platform: event
      event_type: mobile_app_notification_action
      event_data:
        action: lamp_off
    action:
      service: light.turn_off
      entity_id: light.family_room_lamp

What will happen if I fire the “mobile_app_notification_action” now that I have 2 automation’s?

The trigger has 2 parts, first the event_type “mobile_app_notification_action” and second the action in event_data. So it will only fire if the action intheevent data matches the trigger in your automation.

1 Like

For me, I followed the instructions here and now my clicks are working again!

My solution was to turn off mobile background data saving on my phone