Trouble conceiving an automation

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…

How do I accomplish that?

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."

You can add a duration of you only want to know if door is open for x mins

If the door remains open all day, when do you want to be informed of it? At 23:00?

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.

Thanks for thinking of me.

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:

alias: example
variables:
  doors: >
    {{ expand('binary_sensor.door1', 'binary_sensor.door2', 'binary_sensor.door3')
      | selectattr('state', 'eq', 'on') | map(attribute = 'name') | list }}
trigger:
  - platform: state
    entity_id:
      - binary_sensor.door1
      - binary_sensor.door2
      - binary_sensor.door3
    from: 'off'
    to: 'on'
  - platform: time
    at: '23:00:00'
condition:
  - condition: time
    after: '23:00:00'
    before: '08:00:00'
  - '{{ doors | count > 0 }}'
action:
  - service: notify.your_phone
    data:
      message: "Open doors: {{ doors | join(', ') }}"

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.

Good luck with the move and enjoy your new home!