Door open 5 min between 19PM and 21PM : send notification

Hello,

I have the following use case: send notification if a door is open for 5 min between 19:00 - 21:00. I read a lot of topics from the community, but still it is not clear to me how to do it.
Below is the code; I know why is not triggering: the door can be opened before 19:00 and this means I need to put somehow this into the trigger. I saw other examples with a timer, but merely used for repetitive notifications and I need just 1.

alias: 'Notify Door open after 19:00'
description: ''
trigger:
  - platform: state
    entity_id: switch.tasmota_fake_socket
    to: 'on'
    for: '5'
condition:
  - condition: time
    before: '21:00'
    after: '19:00'
action:
  - service: notify.mobile_app_iphone
    data:
      message: Door is open!
mode: single

Thank you!

Not exactly sure what you are asked, but the formatting for ‘for’ is hr:min:sec, below my automation is for 5 minutes of door being open.
You might have to split your times into two separate conditions: one for before 2100 and one for after 1900.
Mine is very similar to yours but I don’t have it based on time; and I also just timestamp the message with a time so I know if it is a new or old message I may have missed.
I also have it check at 5 minutes open and then again at 10 minutes open.

alias: Notification Deep Freezer Door
description: ''
trigger:
  - platform: state
    entity_id: binary_sensor.deep_freezer_door
    to: 'on'
    for: '0:05:00'
  - platform: state
    entity_id: binary_sensor.deep_freezer_door
    to: 'on'
    for: '0:10:00'
condition: []
action:
  - service: notify.mobile_app_gphone
    data:
      message: '{{states[''sensor.time''].state}} Deep Freezer door is open'
  - service: notify.mobile_app_sm_g950u
    data:
      message: '{{states[''sensor.time''].state}} Deep Freezer door is open'
  - service: tts.marytts_say
    entity_id: media_player.rpispeaker1
    data_template:
      message: Deep Freezer Door is Open
mode: single

Hi Glenn,

thanks for the reply. The 5 there is was for a test, sorry.
Maybe I was not clear with the ask, how to I get to receive notifications just for the interval 19:00-21:00 ? The issue with the trigger we both have is that it will trigger every time a door is opened for 5 min. And in my case if the door is already opened before 19:00 and the state will not change to closed and again to opened, my notification will not fire.

Hope I was more clear.

Thx,
Ovidiu

alias: 'Notify Door open after 19:00'
description: ''
trigger:
  - platform: state
    entity_id: switch.tasmota_fake_socket
    to: 'on'
    for: '5'
  - platform: time
    at: '19:00:00'
condition:
  - condition: time
    before: '21:00'
    after: '19:00'
  - condition: state
    entity_id: switch.tasmota_fake_socket
    state: 'on'
action:
  - service: notify.mobile_app_iphone
    data:
      message: Door is open!
mode: single

Hi @finity ,

thanks a lot for the code. I have just a shor q: do I need to add an “and” statement for the conditions? or is by default an and?

conditions are ‘and’ by default.