I have some motion sensors in my toilet and laundry that turn on the LIFX light and start a delay and turn off after 1 minute. The issue I’m having is there are times I’ve noticed that the toilet light thinks it’s in the ‘on’ state when it’s in fact off. I’ve written code around this issue so that every time motion is triggered the light is sent the ‘on’ command, but it doesn’t appear to send it when it already thinks it’s on, or it doesn’t receive it, I’m not sure…
But if i manually turn the light on, it all works correctly. Is there a way to fix this?
light:
- platform: lifx
server: x.x.x.x
broadcast: x.x.x.x
automation:
- alias: "Toilet light on with motion before 10pm"
initial_state: True
hide_entity: False
trigger:
- platform: state
entity_id: binary_sensor.toilet_motion
state: 'on'
condition:
- condition: time
after: '6:00:00'
before: '22:00:00'
action:
- service: homeassistant.turn_on
entity_id: light.toilet
data:
color_temp: 207 # 3500K Neutral
brightness: 255 # 100%
- service: homeassistant.turn_off
entity_id: script.toilet_light_off_script
script:
# toilet light off script
toilet_light_off_script:
alias: "Toilet light off script"
sequence:
- service: script.turn_off
data:
entity_id: script.toilet_light_off_timer
- service: script.turn_on
data:
entity_id: script.toilet_light_off_timer
# toilet light off timer
toilet_light_off_timer:
alias: "Toilet light off timer"
sequence:
- delay:
minutes: 1
#seconds: 10
- service: light.turn_off
data:
entity_id: light.toilet