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 every once 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:
update
just got the chance
error in the log:
2020-04-14 13:50:36 ERROR (MainThread) [homeassistant.helpers.condition] Error during template condition: UndefinedError: 'dict object' has no attribute 'new_state'
2020-04-14 13:50:36 ERROR (MainThread) [homeassistant.helpers.condition] Error during template condition: UndefinedError: 'None' has no attribute 'entity_id'
persistent_notification.github_card_templater
was dismissed, and I would have hoped that would have turned_off input_boolean.github_card_templater
needs some checking…
of course I made a mistake, because the new_state and old_state are used with state_change triggers.
should I then use:
condition:
#check for 'github' so this only fires for selected notification dismissals
condition: template
value_template: >
{{'github' in trigger.event.data.entity_id.split('.')[1]}}
action:
service: input_boolean.turn_off
data_template:
entity_id: >
input_boolean.{{trigger.event.data.entity_id.split('.')[1]}}
?