Clicking on the action button will fire an event called “html5_notification.clicked”, you need useact this event as a trigger in your automation.
Something like:
- alias: 'Turn all lights off when button x pressed on notification'
trigger:
platform: event
event_type: html5_notification.clicked
event_data:
action: name_of_your_action
action:
service: light.turn_off
entity_id: group.all_lights
OK
did it with you code! Thank you.
i still don’y understad basic thing,
how i can “call” the service as a trigger (like i did with PushBullet),
and connect spcific notification for the automation
what i need for example is - when i arraive home (i have google location) , i will get an notification that will ask me if turn on the lights…
hope it’s not too much truble.
alias: ‘Turn all lights off when button x pressed on notification’
I personally don’t want my system asking me whether I want to do something or not, I’d rather have it do things based on certain conditions, like e.g. turn the light on if I arrive home, but only if no one else is home. But to each his own.
You should read about automations here:
And you can find some examples here:
To do it your way, you need two automations. One to send a notification, once you arrive home, which asks if you want to turn on the lights and a second automation that will turn on the light if you press the button on the notification.
First automation to send a notification when you arrive home:
automation:
- alias: 'Send notification to ask to turn light on when someone arrives home'
trigger:
- platform: state
entity_id: group.all_devices
to: 'home'
action:
service: notify.notify
data:
message: 'Just arrived home. Do you want to turn on the kitchen lights?'
action: turn_lights_on #identification of your button
title: Yes
Second automation to turn light on if the button has been pressed.
- alias: 'Turn all lights off when button pressed on notification'
trigger:
platform: event
event_type: html5_notification.clicked
event_data:
action: turn_lights_on #identification of the button specified above
action:
service: switch.turn_on
entity_id: switch.kichten_tablle
Maybe you need to adopt these examples a bit, I don’t work with HA automations so there are probably some errors. Just show your logs if it shouldn’t work.
now…
i have a problem that the new trigger call -html5_notification.clicked-
two times- one for each automation…
(first turn on the lights- after that triger the "good night"automation that closing everthing)
how can i direct each one?
and another quastion- how can i triger “not home” by location for spcific 3 devices i have (not all devices group)
'- id: '157151***02'
alias: 'no one home'
description: ''
trigger: []
condition:
- condition: zone
entity_id: device_tracker.google_maps_ **(here i want to add my devices )**
zone: not_zone.home
action:
- data:
data:
actions:
- action: dismiss
title: no
- action: automation.good_night <= (existing automation I have)
title:yes
message: no one home, close evrything?
service: notify.home'
I made that with the new user inteface- I notice that output worte a bit diffrent order.
You don’t specify the automation as one of the buttons, you just specify a unique identifier like “good_night”. So change this part below:
- data:
data:
actions:
- action: dismiss
title: no
- action: automation.good_night <= (existing automation I have)
title:yes
To this
- data:
data:
actions:
- action: dismiss
title: no
- action: good_night #just put a unique name for the action here
title:yes
The second automation waits for a button being pressed on a notification. If the action of the button (good_night in this case) matches the one specified, the automation will be fired.
- alias: 'Turn all lights off when button pressed on notification'
trigger:
platform: event
event_type: html5_notification.clicked
event_data:
action: good_night #unique name specified above
action:
service: switch.turn_on
entity_id: switch.kichten_tablle
I don’t understand what you want to do. When do you want to start the “good night” automation, right after you returned home?
Just add one trigger for each device to your automation.
I made a mess with everyhing… Ifeel so dump to not understad that!
i have 2 automation-
1- ask if turn on lights when i arraive home=> turn “interior night light”
2- when no on’s home ask if close everthing- “good night”
that what I don’t get- how the click know what automation trigger?
the click automation know how to find the right servies to run without spcific name?
if i will understand one i will get all
what i have now is:
noticiation:
alias: close all good night
description: ''
trigger: []
condition:
- condition: zone
entity_id: device_tracker.google_maps_1130334572677052
zone: not_zone.home
action:
- data:
data:
actions:
- action: dismiss
title: לא
- action: good_night
title: כן
message: there no one home, close evrything?
service: notify.lagziel_home
clicked:
alias: Good night Turn off inerior lights when button pressed on notification
trigger:
- event_data: []
condition: []
action:
- data:
entity_id: switch.salon_tris, switch.dining_tris,switch.livingroom_light, switch.livingroom_hall,
switch.down_diningspot, switch.livingroom_dining,switch.kitchen_tablle,switch.kitchen_main,switch.kitchen_light
service: switch.turn_off
now i don’t get any respones after click on notification.
For each button you want in your notification you specify ‘action’ and ‘title’. ‘title’ is the name of the button you see when you receive the notification. ‘action’ is the identifier of this button. When you press a button, an event will be triggere and this event contains the ‘action’ identifier of the button that has been pressed.
The second automation that listens for the event checks if the event contains the correct identifier.
- alias: 'Good night Turn off inerior lights when button pressed on notification'
trigger:
platform: event
event_type: html5_notification.clicked
event_data:
action: good_night # <- here is the identifier, this automation will only fire if the 'action' in the event is 'good_night'
action:
service: switch.turn_off
entity_id: switch.salon_tris, switch......
Why do you need the “dismiss” button? Should it do something as well? If it doesn’t do anything, just remove it.
As I general rule, as soon as something contains whitespace, I put it in quotes if it’s some text to display and I replace the whitespace with _ if it’s an identifier like an entity or an action. E.g. Welcome, Turn on lights? I change to “Welcome, turn on lights?” Whitespace outside of quotes can make trouble.
I changed your action from turn on interior lights to turn_on_interior_lights, because this is probably the problem why nothing happens on a button press.
I also rearranged it a bit to make it more readable.