Hi, I have an Airbnb and people keep the aircon on, while having doors and windows open. I have an automation which turns the AC off after 3mins of either door or window kept open. The problem is, that often they just turn the AC back on while keeping door/window open. So I’m trying to create an automation which fires after 3 mins of keeping door or window open, and then repeats every 3mins until both door and window is closed. Any of you know how I would do that? I tried to add multiple triggers for 3, 6, 9, 12mins and so on, but it seems only the first trigger fires and the subsequent triggers are then ignored.
Thanks a bunch!
The simplest way is to just check every three minutes:
- id: aircon_auto_off
alias: 'Aircon Auto Off'
trigger:
platform: time_pattern
minutes: '/3'
condition:
- condition: state
entity_id: switch.aircon
state: 'on'
- condition: or
conditions:
- condition: state
entity_id: binary_sensor.window_1
state: 'on'
- condition: state
entity_id: binary_sensor.window_2
state: 'on'
- condition: state
entity_id: binary_sensor.window_3
state: 'on'
- condition: state
entity_id: binary_sensor.door_1 # etc...
state: 'on'
action:
- service: switch.turn_off
entity_id: switch.aircon
Add all your windows and door sensors to the ORed conditions. If any are on (open) the action will fire, if the aircon is on. It will continue to check again 3 minutes later.
Consider separate automations for doors and windows.
Windows are low use and never open momentarily.
Doors are constant use and checking every 3 minute may result in AC OFF if someone is simply walking outside.
Lovely, I’ll try that
I think this is a better option. It will turn off the aircon if it has been on for 3 minutes and any window/door is open. This will re-occur no matter how many times it is turned back on. It will also turn off if a window or door is left open for 3 minutes any time the aircon is on:
- id: aircon_auto_off
alias: 'Aircon Auto Off'
trigger:
- platform: state
entity_id: switch.aircon
to: 'on'
for:
minutes: 3
- platform: state
entity_id: binary_sensor.window_1
to: 'on'
for:
minutes: 3
- platform: state
entity_id: binary_sensor.window_1
to: 'on'
for:
minutes: 3
- platform: state
entity_id: binary_sensor.window_1
to: 'on'
for:
minutes: 3
- platform: state
entity_id: binary_sensor.door_1 # etc...
to: 'on'
for:
minutes: 3
condition:
- condition: state
entity_id: switch.aircon
state: 'on'
- condition: or
conditions:
- condition: state
entity_id: binary_sensor.window_1
state: 'on'
- condition: state
entity_id: binary_sensor.window_2
state: 'on'
- condition: state
entity_id: binary_sensor.window_3
state: 'on'
- condition: state
entity_id: binary_sensor.door_1 # etc...
state: 'on'
action:
- service: switch.turn_off
entity_id: switch.aircon
This also has the advantage of not triggering unless there is a state change, unlike the time pattern trigger version that triggers every three minutes 24/7. You can also adjust the trigger delays for the doors if you want them to be longer.
Thanks Tom. The second solution works only if I have a way to check if the aircon is actually on, which I do not. Therefore it’s sufficient for me to just send an IR signal ‘off’ whenever either or both of the doors are open for 3 minutes and every 3 minutes after that, regardless of AC being on or not.
I’ll give the first solution a go, even though it will trigger 24/7 every 3 minutes. Maybe I’ll slow it to 5 mins
Unfortunately so does the first method, see the condition:
condition:
- condition: state
entity_id: switch.aircon
state: 'on'
The other problem with the first method is that the time the aircon turns on is not synchronised with the time pattern trigger. So the aircon could switch off anywhere between 1sec and 3min after a door or window is opened - not good for doors. The second method does not suffer from this.
yea, but in #1 I can just leave it out. won’t make a difference I think?
Still has this problem:
Try this instead:
- id: aircon_auto_off
alias: 'Aircon Auto Off'
trigger:
platform: time_pattern
minutes: '/3'
condition:
- condition: or
conditions:
- condition: state
entity_id: binary_sensor.window_1
state: 'on'
for:
minutes: 3
- condition: state
entity_id: binary_sensor.window_2
state: 'on'
for:
minutes: 3
- condition: state
entity_id: binary_sensor.window_3
state: 'on'
for:
minutes: 3
- condition: state
entity_id: binary_sensor.door_1 # etc...
state: 'on'
for:
minutes: 3
action:
- service: switch.turn_off
entity_id: switch.aircon
Note the time conditions. This has the following effect:
Opening windows or doors could cause the aircon to turn off from 3min to 6min01sec after they are opened due to lack of synchronisation between the time pattern trigger and the time the window or door was opened.
- alias: 'Guest AC off Open Door'
hide_entity: True
trigger:
- platform: time_pattern
minutes: '/5'
condition:
- condition: or
conditions:
- condition: state
entity_id: binary_sensor.guest_front
state: 'on'
- condition: state
entity_id: binary_sensor.guest_side
state: 'on'
action:
- service: switch.turn_off
entity_id: switch.aircon
Oh I see your point!
This is what I have so far. This should turn off the aircon every 5mins, when either or both doors are kept open for 5 mins and every 5mins after that, regardless of the state of the aircon. Do you see a better solution? Trigger should start with opening of either door, then count 5mins and fire, then fire again every 5mins until both doors are closed.
Thanks a ton!
I updated my comment just before you replied.
Oh no. Now we’re back to square one, I think. What happens if the window has been opened for longer than 3 minutes? I’m not sure. Try it.
- alias: 'Aircon Auto Off'
trigger:
- platform: state
entity_id: binary_sensor.guest_front
to: 'on'
for:
minutes: 3
- platform: state
entity_id: binary_sensor.guest_side
to: 'on'
for:
minutes: 3
condition:
- condition: or
conditions:
- condition: state
entity_id: binary_sensor.guest_front
state: 'on'
- condition: state
entity_id: binary_sensor.guest_side
state: 'on'
action:
- service: switch.turn_off
entity_id: switch.aircon
What about this? Would this work or would it only fire once?
Otherwise I try #3
Only once each for the front and side sensors.
Just had a closer read of state conditions docs. #3 should work. But not well.
The first time a window is opened it will take 3 to 6 minutes to turn off the aircon. If someone turns the aircon back on without closing the window the aircon will turn off between 1sec and 3 min later.
I’m going to have another go with a timer and a couple of automations to synchronise things. Stand by…
EDIT: this should do it exactly as you want:
- create a group with all your guest door and window sensors in it
group:
guest_door_and_window_sensors:
name: Guest Door and Window Sensors
entities:
- binary_sensor.window_1
- binary_sensor.window_2
- binary_sensor.window_3
- binary_sensor.door_1 # etc...
- Create a timer:
timer:
guest_aircon:
duration: '00:03:00'
- Create these two automations:
- id: guest_aircon_timer_start
alias: 'Guest Aircon Timer Start'
trigger:
platform: state
entity_id: group.guest_door_and_window_sensors
to: 'on'
action:
- service: timer.start
entity_id: timer.guest_aircon
- id: guest_aircon_auto_off
alias: 'Guest Aircon Auto Off'
trigger:
platform: event
event_type: timer.finished
event_data:
entity_id: timer.guest_aircon
condition:
condition: state
entity_id: group.guest_door_and_window_sensors
state: 'on'
action:
- service: switch.turn_off
entity_id: switch.aircon
- service: timer.start
entity_id: timer.guest_aircon
This will continue to turn the aircon off every 3 minutes after any door and/or window is opened and only stops doing this when all the doors and windows are closed.
The only downside (because you cant tell the aircon’s state) is that your guests may wonder why the aircon beeps every 3 minutes (if does that when off and you send the off command) when a door or window is left open.
- alias: 'Guest AC Auto Off'
hide_entity: True
trigger:
- platform: time_pattern
minutes: '/3'
condition:
- condition: or
conditions:
- condition: state
entity_id: binary_sensor.guest_front
state: 'on'
for:
minutes: 3
- condition: state
entity_id: binary_sensor.guest_side
state: 'on'
for:
minutes: 3
action:
- service: switch.turn_off
entity_id: switch.aircon
It works! But it seems it fires every 6 mins. Is that possible?
Yes but only the first time.
See my improved version with a timer above.
EDIT: Note that I just edited the automations to correct a mistake with the group entity ids.
works flawlessly, thanks!
No worries. Just out of interest, how are you controlling your air-conditioner?
With a Broadlink RM Mini
The code’s doing exactly what I need.
thank you so much for that.
Just a little question I’d like to receive a call to the phone or Alexa almost a minute before the air conditioner closes
any update on Alexa alert?