@Narfel wrote:
TL/DR: I want a switch that does “turn off all devices, no matter what state they are in or who turned them on” and vice versa
This is a question that most likely has been answered many times over, and i derived my current work in progress with those two helpful threads. The idea is a template switch that flips an input_boolean that is tied to an automation that in turn fires a script for on and one for off. The whole thing works if i use itself (and thus flip the input_boolean) to switch on or off. This way the template switch has its defined state and everyone is happy. But it doesn’t work for when all or single lights or devices were switched on independently (not flipping the input_boolean). My problem (and this is where my logic/understanding gets murky) is that i’m pretty sure the template switch is the wrong tool, since i need a state to work with. But what else then? Add a input_boolean flip to every single device? The reason i need it to be a switch is for hue_emulation/alexa. I have a similar thing with a button on lovelace, but there i can just use call service and run a script (button card).
tap_action: action: call-service service: switch.turn_on
Anyway here is my code so far:
input_boolean: master_switch_input_bool: name: Master switch input boolean initial: off
switch: - platform: template switches: alles: value_template: '{{ states("input_boolean.master_switch_input_bool") }}' friendly_name: 'Everything' turn_on: - service: input_boolean.turn_on entity_id: input_boolean.master_switch_input_bool turn_off: - service: input_boolean.turn_off entity_id: input_boolean.master_switch_input_bool
automation (created with the gui): - id: '1578416796397' alias: Bool Turn Lights on description: '' trigger: - entity_id: input_boolean.master_switch_input_bool from: 'off' platform: state to: 'on' condition: [] action: - data: {} entity_id: script.1578416156582 service: script.turn_on - id: '1578416881785' alias: Bool Turn Lights off description: '' trigger: - entity_id: input_boolean.master_switch_input_bool from: 'on' platform: state to: 'off' condition: [] action: - entity_id: script.1578416094874 service: script.turn_on
Posts: 2
Participants: 2