Hi, I’m facing a complicated automation for a newbie.
The automation must respond to 4 conditions:
1 - a door sensor detects that I have opened the garage door
2 - a second sensor detects the opening of an interior door
3 - this second opening must not exceed 10 minutes of the first opening
4 - within this period it is possible that the outer gate closes but the automation should not stop until the 10 minutes have elapsed
I would appreciate any kind of help.
I have tried with this automation but it does not work as I want
- id: 'welcome home'
alias: 'welcome home'
trigger:
- platform: time # debe tener una condicion temporizada , de tiempo
minutes: '/10'
seconds: 00
- platform: state
entity_id: binary_sensor.door2
to: 'on'
condition:
condition: and
conditions:
condition: template
value_template: '{{ (as_timestamp(now())-as_timestamp(states.switch.osram3.last_updated)) > 10 }}'
action:
- service: tts.google_say
data:
entity_id: media_player.home
message: welcome home
It works half-way, the automation does not return to the resting state. That is, while the switch is “on”, it does not stop executing the action .
I just checked that with the switch “off” does not stop the automation either
From your description, some things are not clear. E.g., …
Would that sensor be binary_sensor.door2, and when the garage door opens, does its state to go 'on'?
What sensor would that be, and what state indicates the interior door is open?
By “outer gate” do you mean the garage door? If not, what do you mean? I.e., what entity indicates the state of the “outer gate”?
Regarding the sequence of things and what you want the automation to do, I believe you want it to play the welcome home message if the interior door opens within ten minutes of the garage door opening, even if the garage door closes within those ten minutes. But if the interior door opens any other time, the message should not play. Is that right?
I would implement it the following way. I’ll use binary_sensor.garage_door and binary_sensor.interior_door, so just substitute as needed.
timer:
garage_door_timer:
duration: '00:10:00'
automation:
- alias: Garage door opened
trigger:
platform: state
entity_id: binary_sensor.garage_door
to: 'on'
action:
service: timer.start
entity_id: timer.garage_door_timer
- alias: Interior door opened
trigger:
platform: state
entity_id: binary_sensor.interior_door
to: 'on'
condition:
condition: state
entity_id: timer.garage_door_timer
state: 'active'
action:
# Cancel the garage door timer so this can only
# happen once after garage door is opened.
- service: timer.cancel
entity_id: timer.garage_door_timer
- service: tts.google_say
data:
entity_id: media_player.home
message: welcome home
Yeah thats it . Great , now i need to complicate a little more , i need a sun condition .
How is it but the automation need the sun set .
Do i need to add an and condition with the sun component ?
Thanks in advance