this post was submitted on 27 Jan 2024
15 points (89.5% liked)
homeassistant
12215 readers
16 users here now
Home Assistant is open source home automation that puts local control and privacy first. Powered by a worldwide community of tinkerers and DIY enthusiasts. Perfect to run on a Raspberry Pi or a local server. Available for free at home-assistant.io
founded 2 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
You should be able to handle this in HA within a single automation:
Trigger: Room is occupied (occupancy > 0)
Condition: Light off
Action:
If you are basing your occupancy on more than one sensor state, you could build a helper to combine the states into a single sensor value, which itself might need a Hysteresis helper.
I've started moving some of my own automations over to this method. It works pretty well, but it is susceptible to being interrupted by restarts or reboots. You may need to build in additional logic to reset things to a known state on startup.
Bloody hell! So I saw this and it was like my vision cleared! I'm actually lost for words, but thank you. I don't know why I didn't realise what
wait for trigger
did, but holy fuck, you're beautiful, thank you so much!It's also important to set the mode of the automation to "restart", then it works flawlessly
Aha! THAT'S what that does. Thank YOU too!
I don't want to set a misunderstanding: this does not solve the state on reboot issue, maybe "flawlessly" is not the correct word. On a reboot, all automations are always stopped, so that does not help here.
No, no. I do sometimes have to contend with race conditions and reentrant triggers. I never considered looking into whether it was possible to change the execution mode, even if I did read that documentation without understanding what it meant.
Thanks for the pointer back to it. Now I grok it.
What do you mean? Is that different than
repeat until
?Nope, n00b: https://www.home-assistant.io/docs/automation/modes/