Hi I am trying to automate so that when my door is unlocked between sunset and sunrise I would like to open entrance light.
I have been trying this code ( didn’t put sunrise to sunset yet)
When ulocking door the light does not open.
If I go to the automations section in overview and trigger it the light opens.
What am I doing wrong with my code?
- alias: turn on entrance light when august unlocked
trigger:
platform: state
entity_id: unlock.front_door
to: 'on'
action:
service: homeassistant.turn_on
entity_id: light.53411381807d3a597774
Doesnt seem to be much info for this on the HA wiki, and I dont have one myself but I would assume you need to track the state of the lock entity when it changes to unlocked.
What entity gets created when you add the August lock, and what states does it show (unlocked, locked)? What is unlock.front_door?
Since I can’t see the unlocked state, and I assume its just ‘unlocked’, this should work
- alias: turn on entrance light when august unlocked
trigger:
platform: state
entity_id: lock.front_door
to: 'unlocked'
action:
service: homeassistant.turn_on
entity_id: light.53411381807d3a597774
To prevent any issue where the lock goes unavailable and then back to unlocked, you might want to put ‘from: locked’ before ‘to: unlocked’