Hi Folks, I’m very knew to Home Assistant. I’ve installed several Smart LEDs in my Bathroom and I have my automation “sort of” working. But im struggling with how to keep the lights on for longer when somebody is in the room.
Im using the IKEA Vallhorn sensors via Zigbee. I’m not sure if I should perhaps be using a scene or an automation to achieve this or if my automation just configured incorrectly.The automation flow is Person enters > If before 11PM > Lights ON (Normal Colour) else > after 11PM lights turn ON (Red)
alias: Automation - Bathroom Lights ON
description: ""
trigger:
# Trigger when motion is detected (sensor state changes to 'on')
- platform: state
entity_id: binary_sensor.sensor_bathroom_occupancy
to: "on"
# Trigger when no motion is detected (sensor state changes to 'off')
- platform: state
entity_id: binary_sensor.sensor_bathroom_occupancy
to: "off"
conditions:
- condition: numeric_state
entity_id: sensor.sensor_bathroom_illuminance
below: 10
action:
- choose:
# Turn on lights if motion is detected
- conditions:
- condition: state
entity_id: binary_sensor.sensor_bathroom_occupancy
state: "on"
sequence:
- choose:
- conditions:
- condition: time
before: "23:00:00"
sequence:
- service: light.turn_on
target:
entity_id: light.bathroom_lights
data:
kelvin: 2000
brightness_pct: 44
- conditions:
- condition: time
after: "23:00:00"
sequence:
- service: light.turn_on
target:
entity_id: light.bathroom_lights
data:
color_name: red
brightness_pct: 50
# Turn off lights if no motion is detected
- conditions:
- condition: state
entity_id: binary_sensor.sensor_bathroom_occupancy
state: "off"
sequence:
- service: light.turn_off
target:
entity_id: light.bathroom_lights
mode: restart