So, I’ve figured out automation enough to create one. But my quandary is the nature of my automation. Here’s my pseudo-code:
If (After 23:00 ) and (Before 08:00)
If (Door1 is open) or (Door2 is open) or (Door3 is open)*
Send a message to my phone.*
That should work fine, but I need it to run periodically (say, every 30 minutes), or sleep and repeat. Because the door could open at 23:15. It could also (and likely will) be opened at 09:00 and stay open all day…
I’m not sure this is exactly what you want but let’s use this as a starting point. If any of the three doors is opened during the specified time period, a notification is sent to your phone telling you which door just opened.
alias: example
trigger:
- platform: state
entity_id:
- binary_sensor.door1
- binary_sensor.door2
- binary_sensor.door3
from: 'off'
to: 'on'
condition:
- condition: time
after: '23:00:00'
before: '08:00:00'
action:
- service: notify.your_phone
data:
message: "{{ trigger.to_state.name }} just opened."
The door(s) might remain open for hours for a valid reason, but rarely open after 2300. I am forever failing to close the door and it ends up remaining open all night. So, Can I code an automation to run every hour? Every ten minutes? I understand how to check the conditions, it’s the trigger I can’t fathom.
It’s not necessary to periodically poll the status of all three doors. You said you were only interested in being notified of any doors that are either left open past 23:00 or opened after 23:00. The following automation will do that:
Taras, I’m in the midst of a move to a new home, so I haven’t had a chance to work through this yet. It looks like you’ve satisfied my requirements, and I thank you for helping me with it. I’ll reply again when I’ve had a chance to try it out.