-
-
Notifications
You must be signed in to change notification settings - Fork 187
Examples
The examples are either in YAML, NodeRed or both. For those unfamiliar with YAML or NodeRed, please take a look at the Home Assistant Documentation for YAML and for NodeRed please checkout this great setup guide:
Expand - NodeRed
Import the following JSON into your NodeRed installation.
Expand - YAML
automation:
- alias: Turn off the lights if no one responds to at home question
trigger:
platform: state
entity_id: group.people
to: 'off'
for:
minutes: 5
action:
- service: script.activate_alexa_actionable_notification
data_template:
text: 'Is anyone home?'
event_id: 'alexa_notification_anyone_home'
alexa_device: 'media_player.living_room_echo'
- alias: No response for alexa_notification_anyone_home question
trigger:
platform: event
event_type: alexa_actionable_notification
event_data:
event_id: alexa_notification_anyone_home
event_response: ResponseNone
action:
- service: light.turn_off
entity_id: group.all_lights
Expand - YAML
automation:
- alias: Bedroom lights left on for 30 minutes no motion detected
trigger:
platform: state
entity_id: binary_sensor.bedroom_motion
to: 'off'
for:
minutes: 30
condition:
- condition: state
entity_id: light.bedroom_lights
state: 'on'
action:
- service: script.activate_alexa_actionable_notification
data_template:
text: 'Is anyone in the bedroom?'
event_id: 'alexa_notification_bedroom_occupied'
alexa_device: 'media_player.bedroom_echo'
- alias: No response for alexa_notification_bedroom_occupied question
trigger:
platform: event
event_type: alexa_actionable_notification
event_data:
event_id: alexa_notification_bedroom_occupied
event_response: ResponseNo
action:
- service: light.turn_off
entity_id: group.all_lights
Expand - NodeRed
What it looks like:
Import the following JSON into your NodeRed installation.
[{"id":"5a8efc97.c224f4","type":"api-call-service","z":"e8fe01ef.ddafd","name":"Alexa Actionable Notification - Garage Door OPEN","server":"9f230d2c.1e00d","version":1,"debugenabled":false,"service_domain":"script","service":"activate_alexa_actionable_notification","entityId":"","data":"{\"text\":\"Its getting late and the garage is still open. Would you like me to close it?\",\"event_id\":\"actionable_notification_garage\",\"alexa_device\":\"media_player.your_device\"}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":750,"y":1240,"wires":[[]]},{"id":"b81c86aa.cffd98","type":"api-current-state","z":"e8fe01ef.ddafd","name":"Is Garage Open?","server":"cf2d0f67.b78c5","version":1,"outputs":2,"halt_if":"open","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"cover.your_device","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":430,"y":1240,"wires":[["5a8efc97.c224f4"],[]]},{"id":"29219c0.fd93164","type":"inject","z":"e8fe01ef.ddafd","name":"","topic":"","payload":"true","payloadType":"bool","repeat":"","crontab":"42 19 * * *","once":false,"onceDelay":0.1,"x":250,"y":1240,"wires":[["b81c86aa.cffd98"]]},{"id":"f2a004b3.987308","type":"api-call-service","z":"e8fe01ef.ddafd","name":"Garage Door - Close","server":"cf2d0f67.b78c5","version":1,"debugenabled":false,"service_domain":"cover","service":"close_cover","entityId":"cover.your_device","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1020,"y":1360,"wires":[[]]},{"id":"1cc5f7ea.344078","type":"switch","z":"e8fe01ef.ddafd","name":"Notification Response","property":"payload.event.event_response","propertyType":"msg","rules":[{"t":"eq","v":"ResponseYes","vt":"str"},{"t":"eq","v":"ResponseNo","vt":"str"},{"t":"eq","v":"ResponseNone","vt":"str"}],"checkall":"true","repair":false,"outputs":3,"x":780,"y":1360,"wires":[["f2a004b3.987308"],[],["f2a004b3.987308"]]},{"id":"1b3e6beb.9ca094","type":"switch","z":"e8fe01ef.ddafd","name":"Notification Check","property":"payload.event.event_id","propertyType":"msg","rules":[{"t":"eq","v":"actionable_notification_garage","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":550,"y":1360,"wires":[["1cc5f7ea.344078"]]},{"id":"4778008.13c87","type":"server-events","z":"e8fe01ef.ddafd","name":"Alexa Notification Response","server":"cf2d0f67.b78c5","event_type":"alexa_actionable_notification","exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"x":300,"y":1360,"wires":[["1b3e6beb.9ca094"]]},{"id":"9f230d2c.1e00d","type":"server","z":"","name":"Home Assistant","legacy":false,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":false,"cacheJson":true},{"id":"cf2d0f67.b78c5","type":"server","z":"","name":"Home Assistant"}]
Expand - YAML
automation:
- alias: Garage door opened at 9pm.
trigger:
platform: time
# Military time format. This trigger will fire at 9pm
at: "21:00:00"
action:
- service: script.activate_alexa_actionable_notification
data_template:
text: 'Its getting late and the garage is still open. Would you like me to close it?'
event_id: 'actionable_notification_garage'
alexa_device: 'media_player.living_room_echo'
- alias: Yes response to alexa_cooling_set_sleep.
trigger:
platform: event
event_type: alexa_actionable_notificaiton
event_data:
event_id: actionable_notification_garage
event_response: ResponseYes
action:
- service: cover.close_cover
entity_id: cover.garage_door
Expand - Node-RED
How to Import code into node red:
[{"id":"831685e2.386948","type":"api-call-service","z":"416e642e.953dec","name":"TV","server":"cf2d0f67.b78c5","version":1,"debugenabled":false,"service_domain":"switch","service":"turn_off","entityId":"switch.sheldons_lights","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1050,"y":300,"wires":[[]]},{"id":"811cd95.ca88b28","type":"server-events","z":"416e642e.953dec","name":"Alexa Notification Response","server":"cf2d0f67.b78c5","event_type":"alexa_actionable_notification","exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"x":380,"y":300,"wires":[["6335fbd1.02b644"]]},{"id":"6335fbd1.02b644","type":"switch","z":"416e642e.953dec","name":"Notification Check","property":"payload.event.event_id","propertyType":"msg","rules":[{"t":"eq","v":"actionable_notification_testshelly","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":630,"y":300,"wires":[["4e38744a.eab68c"]]},{"id":"4e38744a.eab68c","type":"switch","z":"416e642e.953dec","name":"Notification Response","property":"payload.event.event_response","propertyType":"msg","rules":[{"t":"eq","v":"ResponseYes","vt":"str"},{"t":"eq","v":"ResponseNo","vt":"str"},{"t":"eq","v":"ResponseNone","vt":"str"}],"checkall":"true","repair":false,"outputs":3,"x":860,"y":300,"wires":[["831685e2.386948"],[],["b94a2d10.9ee13"]]},{"id":"ddb415e1.9565b8","type":"api-current-state","z":"416e642e.953dec","name":"TV ON","server":"cf2d0f67.b78c5","version":1,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"switch.your_lights","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":470,"y":220,"wires":[["13ce4701.711069"],[]]},{"id":"13ce4701.711069","type":"api-call-service","z":"416e642e.953dec","name":"Alexa Actionable Notification - Light On","server":"9f230d2c.1e00d","version":1,"debugenabled":false,"service_domain":"script","service":"activate_alexa_actionable_notification","entityId":"","data":"{\"text\":\"This is a test. Would you like me to turn off the lights?\",\"event_id\":\"actionable_notification_testshelly\",\"alexa_device\":\"media_player.downstairs\"}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":790,"y":220,"wires":[[]]},{"id":"8bc7288b.ee7378","type":"inject","z":"416e642e.953dec","name":"","topic":"","payload":"true","payloadType":"bool","repeat":"","crontab":"00 20 * * *","once":false,"onceDelay":0.1,"x":330,"y":220,"wires":[["ddb415e1.9565b8"]]},{"id":"4fa7f031.cebbf","type":"api-call-service","z":"416e642e.953dec","name":"Alexa Actionable Notification - Light On","server":"9f230d2c.1e00d","version":1,"debugenabled":false,"service_domain":"script","service":"activate_alexa_actionable_notification","entityId":"","data":"{\"text\":\"This is the second test on another device.\",\"event_id\":\"actionable_notification_testshelly2\",\"alexa_device\":\"media_player.conner_s_room\"}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1150,"y":360,"wires":[[]]},{"id":"4d23773d.1131d8","type":"api-call-service","z":"416e642e.953dec","name":"TV","server":"cf2d0f67.b78c5","version":1,"debugenabled":false,"service_domain":"switch","service":"turn_off","entityId":"switch.your_lights","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1050,"y":460,"wires":[[]]},{"id":"7bf864f3.7dccec","type":"server-events","z":"416e642e.953dec","name":"Alexa Notification Response","server":"cf2d0f67.b78c5","event_type":"alexa_actionable_notification","exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"x":380,"y":460,"wires":[["9d846357.21537"]]},{"id":"9d846357.21537","type":"switch","z":"416e642e.953dec","name":"Notification Check","property":"payload.event.event_id","propertyType":"msg","rules":[{"t":"eq","v":"actionable_notification_testshelly2","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":630,"y":460,"wires":[["8cfb9ed5.82d93"]]},{"id":"8cfb9ed5.82d93","type":"switch","z":"416e642e.953dec","name":"Notification Response","property":"payload.event.event_response","propertyType":"msg","rules":[{"t":"eq","v":"ResponseYes","vt":"str"},{"t":"eq","v":"ResponseNo","vt":"str"},{"t":"eq","v":"ResponseNone","vt":"str"}],"checkall":"true","repair":false,"outputs":3,"x":860,"y":460,"wires":[["4d23773d.1131d8"],[],[]]},{"id":"b94a2d10.9ee13","type":"api-current-state","z":"416e642e.953dec","name":"TV ON","server":"cf2d0f67.b78c5","version":1,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"switch.your_light","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":890,"y":360,"wires":[["4fa7f031.cebbf"],[]]},{"id":"cf2d0f67.b78c5","type":"server","z":"","name":"Home Assistant"},{"id":"9f230d2c.1e00d","type":"server","z":"","name":"Home Assistant","legacy":false,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":false,"cacheJson":true}]
Expand - YAML
automation:
- alias: Going to sleep and thermostat not set to 74.
trigger:
platform: state
entity_id: group.people_sleep
to: 'on'
condition:
- condition: template
value_template: "{{ states.climate.thermostat.attributes.temperature > 74 }}"
- condition: state
entity_id: climate.building_36_technologies_unknown_type_0001_id_0001_mode
state: 'cool'
action:
- service: script.activate_alexa_actionable_notification
data_template:
text: 'Would you like me to set the thermostat to 74?'
event_id: 'alexa_cooling_set_sleep'
alexa_device: 'media_player.bedroom_echo'
- alias: Yes response to alexa_cooling_set_sleep.
trigger:
platform: event
event_type: alexa_actionable_notificaiton
event_data:
event_id: alexa.cooling.sleep.set
event_response: ResponseYes
action:
- service: climate.set_temperature
entity_id: climate.thermostat
data:
temperature: 74
If you get an error with the skills response:
For the URL make sure you are using an external URL and not your personal internal IP that you use to access the HA dashboard.
Make sure you setup port forwarding to let HA communicate to outside your firewall.
Go to this video and watch how to port forward, create a URL, and setup the DNS in Home Assistant. https://www.youtube.com/watch?v=jkBcGl7Vq8s