HA can receive a state change for the light, on/off.
Let me explain the problem more in depth if that helps:
There are two components:
I want to achieve three things:
- When someone walks in the room, turn on the light, and when there is no motion detected for 1 minute, turn off the light. This automation works
- When someone walks in the room (lights turn on), and then presses the switch, the lights go off, and as long that there is motion in the room, the lights stay off.
- When someone walks in the room (lights turn on(, and hen presses the switch to turn off the light and within 5 seconds or so presses the switch again it turns back on the light, but then the lights should stay on forever
I tried the option provided with the input_boolean, when the sensor picks up motion it turns on the lights and sets the input_boolean.lights_on_by_motion to “on”.
I want the script that turns of the lights after a delay, to check if input_boolean.lights_on_by_motion is " on",
At every other state change from the light I clear input_boolean.lights_on_by_motion back to “off”, so that the automatic turning off fort the lightning can be ignored
The problem is then in the script thats turns off the lights, after a delay of 1 minute. I cant check the value of the input_boolean because I cant use conditions in a script sequence…
example code below:
The automation that kicks off the script to turn on the light:
alias: Keukenlamp aan bij beweging en zet deze na 1 minuut weer uit
trigger:
- platform: state
entity_id: sensor.fibaro_system_fgms001_motion_sensor_burglar_4
state: "8"
action:
service: homeassistant.turn_on
entity_id: script.keukenlamp_aan_voor_10_minuten
The script that turns on the light and sets the input_boolean value:
sequence:
- service: script.turn_off
data:
entity_id: script.keukenlamp_uit_na_delay
- service: light.turn_on
data:
entity_id: light.fibaro_system_fgd212_dimmer_2_level_2
- service: homeassistant.turn_on
data:
entity_id: input_boolean.licht_keuken_aan_door_beweging
- service: script.turn_on
data:
entity_id: script.keukenlamp_uit_na_delay
The script that turns off the light: (called by previous script)
sequence:
- delay:
minutes: 1
- service: light.turn_off
data:
entity_id: light.fibaro_system_fgd212_dimmer_2_level_2
transition: 8
- service: homeassistant.turn_off
data:
entity_id: input_boolean.licht_keuken_aan_door_beweging
The problem is that in the last script here above I want to check the condition of the input_boolean, AFTER the delay. so that if the light was turned on by motion it is ’ ok’ to auto turn off, with every other state change of the light in the meantime I can reset the input_boolean so that the light wont get turned off automaticaly…
But how to do conditions in a script sequence? looks like it is not possible… I get the following error when I try:
Invalid config for [script]: [condition] is an invalid option for [script]
Is what I want even possible? Or am I trying to tackle the problem in the wrong way?
Any help welcome!