Skip to content

Instantly share code, notes, and snippets.

@dlashua
Created August 13, 2019 10:21
Show Gist options
  • Save dlashua/a7c1d4b09ce36cf295b81c434d8f06e0 to your computer and use it in GitHub Desktop.
Save dlashua/a7c1d4b09ce36cf295b81c434d8f06e0 to your computer and use it in GitHub Desktop.
notify alexa
devices = [
{
"device_entity": "media_player.dance_echo",
"active_entity": "binary_sensor.dance_echo_notifications",
},
{
"device_entity": "media_player.celeste_echo",
"active_entity": "binary_sensor.celestebed_echo_notifications",
},
{
"device_entity": "media_player.daniel_echoshow",
"active_entity": "binary_sensor.danielbed_echo_notifications",
},
{
"device_entity": "media_player.living_echo",
"active_entity": "binary_sensor.living_echo_notifications",
},
{
"device_entity": "media_player.office_echo",
"active_entity": "binary_sensor.office_echo_notifications",
},
{
"device_entity": "media_player.masterbath_echo",
"active_entity": "binary_sensor.masterbath_echo_notifications",
},
]
message = data.get("message", None)
if message is None:
logger.error("NO MESSAGE")
exit
devices_to_notify = []
for room in devices:
active = hass.states.get(room["active_entity"]).state
if active == 'on':
devices_to_notify.append(room["device_entity"])
if (devices_to_notify):
hass.services.call("notify","alexa_media", {
"message": message,
"data": {
"type": "announce",
"method": "speak",
},
"target": devices_to_notify
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment