hyukang
(Paul Kang)
August 16, 2017, 7:13am
1
I have 2 hue lights and 1 switch I want to turn off. This format doesn’t seem to work.
- alias: Turn OFF Office When Motion Not Detected
trigger:
platform: state
entity_id: binary_sensor.office_sensor_sensor
from: 'on'
to: 'off'
for:
minutes: 3
condition:
- condition: state
entity_id:
- switch.office_lights_switch
- light.office_desk_left
- light.office_desk_right
state: 'on'
action:
- service: switch.turn_off
entity_id: switch.office_lights_switch
- service: light.turn_off
entity_id:
- light.office_desk_left
- light.office_desk_right
keithh666
(Keith Hull)
August 16, 2017, 3:04pm
2
I normally do it like this …
action:
- service: homeassistant.turn_off
entity_id:
- light.zw_uplight_dimmer_level
- switch.pilivingroomceilingdimmer
- switch.pilivingroomfire
- switch.pilivingroomantminer
- switch.pikitchenheaterminer
- switch.pilivingroomlavalamp
- switch.zw_tvandsoundbar_switch
hyukang
(Paul Kang)
August 16, 2017, 3:18pm
3
This is the portion I’m having trouble with
condition:
- condition: state
entity_id:
- switch.office_lights_switch
- light.office_desk_left
- light.office_desk_right
state: 'on'
How do I make it so that HA looks at each light to see if it’s on… and turn it off if it’s on
currently I’m using this
trigger:
platform: state
entity_id: binary_sensor.office_sensor_sensor
from: 'on'
to: 'off'
for:
minutes: 3
condition:
condition: state
entity_id: switch.office_lights_switch
state: 'on'
Which tell HA to see if only 1 light is on. This glitches sometimes and only turns off that switch instead of the all 3
I don’t think you need the from: 'on'
line.
keithh666
(Keith Hull)
August 16, 2017, 4:06pm
5
I’m pretty sure that you don’t need the condition at all, since HA knows what’s on and what’s off and even if it didn’t because it was out of sync with the lights/switches, it would be good practice to turn them off anyway to resync the actual with what HA thinks.
Tinkerer
(aka DubhAd on GitHub)
August 16, 2017, 4:41pm
6
Depending on whether you want to check if all lights are on, or just one, you’ll need to use and
or or
as explained here .
condition:
- condition: or
conditions:
- condition: state
state: 'on'
entity_id: switch.office_lights_switch
- condition: state
state: 'on'
entity_id: light.office_desk_left
- condition: state
state: 'on'
entity_id: light.office_desk_right
Of course, if you don’t care, just remove the conditions.
hyukang
(Paul Kang)
August 17, 2017, 3:02am
7
Thank you that worked perfectly