Hello, I only recently started doing some automation on HA, I have all devices from Philips Hue, but got them ‘disable’ on Hue app and do the automations on HA.
I got some lights that turn on with a montion sensor, and I’m doing a automation to bypass that.
But the part that I need help is to make this automation check if some one forget to turn off lights after 30min.
If they forget to turn lights off on the switch and there is no montion on last 5 minutes, the automation should proceed with turn off switch, if there is montion detection on last 5min it shouls start a repeat check every 5 minutes, until there is no montion detect on last 5min.
Here is the code I have right now:
trigger:
- platform: state
entity_id:
- input_boolean.x
condition: []
action:
- choose:
- conditions:
- condition: state
entity_id: input_boolean.x
state: "on"
sequence:
- service: adaptive_lighting.apply
data:
lights:
- light.a
- light.b
entity_id: switch.adaptive_lighting.y
transition: "3"
turn_on_lights: true
adapt_color: true
adapt_brightness: true
- service: automation.turn_off
data:
stop_actions: true
target:
entity_id: automation.montion_control_lights
- conditions:
- condition: state
entity_id: input_boolean.x
state: "off"
sequence:
- service: light.turn_off
data:
transition: 10
target:
entity_id:
- light.a
- light.b
- service: automation.turn_on
data: {}
target:
entity_id: automation.montion_control_lights
- delay:
hours: 0
minutes: 30
seconds: 0
milliseconds: 0
- choose:
- conditions:
- condition: and
conditions:
- condition: state
entity_id: binary_sensor.sensor_montion
state: "off"
for:
minutes: 5
- condition: or
conditions:
- condition: state
entity_id: light.a
state: "on"
- condition: state
entity_id: light.b
state: "on"
sequence:
- service: input_boolean.turn_off
data: {}
target:
entity_id: input_boolean.x
- conditions:
- condition: and
conditions:
- condition: state
entity_id: binary_sensor.sensor_motion
state: "on"
for:
minutes: 5
- condition: state
entity_id: light.a
state: "on"
- condition: state
entity_id: light.b
state: "on"
sequence:
- repeat:
while:
- condition: state
entity_id: binary_sensor.sensor_motion
for:
minutes: 5
state: "on"
sequence: []