I have a button installed in my dashboard to switch on/off all 3 lights in my living room.
The button is connected to a boolean helper.
Then I wrote a code / automation:
Tap on button:
if no lights on = switch all lights on
if 1 or more lights are switched on → switch all lights off
This works pretty well. This is my code:
alias: Wohnzimmer alles ein/aus
description: ""
trigger:
- platform: state
entity_id:
- input_boolean.wohnzimmer_alles_ein_aus
condition: []
action:
- choose:
- conditions:
- condition: or
conditions:
- condition: device
type: is_on
device_id: ab847b7665a907fa0b71097e0553e4f0
entity_id: 01f0e6f78b449e0268bb1636d9c5a8ab
domain: switch
- condition: device
type: is_on
device_id: 26de39eb504f6428444b743d42a3bdb8
entity_id: 156403216d8e647aebd46192400b76c1
domain: light
- condition: device
type: is_on
device_id: 7a48fb8074706d3bad472831746dead5
entity_id: c3c99bfef0a275b78ca374b98ecb2c50
domain: light
sequence:
- type: turn_off
device_id: ab847b7665a907fa0b71097e0553e4f0
entity_id: 01f0e6f78b449e0268bb1636d9c5a8ab
domain: switch
- type: turn_off
device_id: 26de39eb504f6428444b743d42a3bdb8
entity_id: 156403216d8e647aebd46192400b76c1
domain: light
- type: turn_off
device_id: 7a48fb8074706d3bad472831746dead5
entity_id: c3c99bfef0a275b78ca374b98ecb2c50
domain: light
default:
- type: turn_on
device_id: ab847b7665a907fa0b71097e0553e4f0
entity_id: 01f0e6f78b449e0268bb1636d9c5a8ab
domain: switch
- type: turn_on
device_id: 26de39eb504f6428444b743d42a3bdb8
entity_id: 156403216d8e647aebd46192400b76c1
domain: light
- type: turn_on
device_id: 7a48fb8074706d3bad472831746dead5
entity_id: c3c99bfef0a275b78ca374b98ecb2c50
domain: light
mode: single
But now I have the problem, that the button does not display correctly if the lights are on or off.
So I created another automation to check if all lights are off → boolean = 0. Works.
But now I want to display the button as “on” if just one or more lights are turned on. But this actually triggers the first automation to switch on ALL lights.
Is there an easier way to display the button as “on” even if there is just f.e. ONE light turned on?