Quantcast
Channel: Configuration - Home Assistant Community
Viewing all articles
Browse latest Browse all 95441

Please check correct trigger and id in this automation

$
0
0

@Mariusthvdb wrote:

using this automation:

  - alias: 'GitHub repo update installed'
    trigger:
      platform: event
      event_type: state_changed
    condition:
      - condition: template
        value_template: >
          {{trigger.event.data.new_state.entity_id.startswith('input_boolean.github')}}
      - condition: template
        value_template: >
          {{trigger.event.data.new_state.state == 'off' and
            trigger.event.data.old_state.state  == 'on'}}
    action:
      service: persistent_notification.dismiss
      data_template:
        notification_id: >
          {{trigger.event.data.new_state.object_id}}

dismisses the persistent_notification when the input_boolean is turned off.

Id like to add an automation to do the exact same in reverse: turn_off the input_boolean, when the persistent_notification is dismissed.
but I am puzzled which service to use as trigger (for starters…) Can I use an event trigger on the call-service?

if so, what would be the way to get the correct trigger service-data so I can pass the notification-id over to the input_boolean to dismiss it…

  - alias: 'Persistent notification dismissal turns off boolean'
    trigger:
      platform: event
      event_type: call_service
      event_data:
        domain: persistent_notification
        service: dismiss
    condition:
      #check for 'github' so this only fires for selected notification dismissals
      condition: template
      value_template: >
        {{'github' in trigger.event.data.new_state.object_id}}
    action:
      service: input_boolean.turn_off
      data_template:
        entity_id: >
          input_boolean.{{trigger.event.data.new_state.object_id}}
        

would this be close?
thanks for having a look.

extra reason I seek your assistance is this cant very easily be tested, because only very nice in a while a new GitHub repo update occurs… I need some keen eyes to check if I made no syntax or logic errors.

also, in the events list on developer-tools/event, the dismiss isn’t listed. only see this:

Schermafbeelding 2020-04-14 om 12.43.43

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 95441

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>