Hi
Using Dasher (https://github.com/maddox/dasher) and a series of automation scripts, i have managed to turn all my devices off if they are on and on if they are off, by triggering one automation script which is sent from the Dash button and using the HA API. I picked a trigger/state of a device i know will never fire as i only want to trigger this automation when i say so.
Here’s the automation and the json you need to upload to the dash button (follow the simple guide in link):
{"buttons":[
{
"name": "Turn on Script from Dash Button",
"address": "74:c2:46:xx:xx:xx", # mac address
"timeout": "60000",
"protocol": "udp",
"url": "https://duckdns.org:8123/api/services/automation/trigger",
"method": "POST",
"headers": {"x-ha-access": ""}, # password here
"json": true,
"body": {"entity_id": "automation.dash_button__all_off"}
}]}
automation dash button off:
alias: dash off
initial_state: True
hide_entity: False
trigger:
platform: state
entity_id: media_player.kodi
to: 'stopped'
action:
- service: homeassistant.turn_off
entity_id: light.large_l,light.small_l,light.stairs,light.kitchen,switch.testing_hyperion,media_player.sony_tv
- service: homeassistant.turn_on
entity_id: switch.kodi_input_amp
automation dash button on:
alias: dash on
initial_state: True
hide_entity: False
trigger:
platform: state
entity_id: media_player.kodi
to: 'stopped'
action:
- service: homeassistant.turn_on
entity_id: light.large_l,light.small_l,light.stairs,light.kitchen,switch.testing_hyperion,media_player.sony_tv
- service: homeassistant.turn_on
entity_id: switch.television_input_amp
automation dash button:
alias: Dash button - all off
initial_state: True
hide_entity: False
trigger:
platform: state
entity_id: media_player.kodi
to: 'stopped'
action:
- service: automation.trigger
data_template:
entity_id: >-
{% if is_state('light.large_l', 'on') %}
automation.dash_off
{% else %}
automation.dash_on
{% endif %}
Cant seem to get the yaml in the right format so heres an attachment:
automation.yaml (1.3 KB)