Skip to content

Instantly share code, notes, and snippets.

@lukeredpath
Last active July 23, 2025 14:27
Show Gist options
  • Save lukeredpath/faef51eb9d28d02328225dfe7ef2ef19 to your computer and use it in GitHub Desktop.
Save lukeredpath/faef51eb9d28d02328225dfe7ef2ef19 to your computer and use it in GitHub Desktop.
HA Automation - Turn off aircon when door left open
alias: Open Office Aircon Control
description: Ensures the aircon is turned off if the door is left open
triggers:
- alias: Door left open
type: opened
device_id: xxx
entity_id: xxx
domain: binary_sensor
trigger: device
for:
hours: 0
minutes: 2
seconds: 0
id: door_left_open
- type: not_opened
device_id: xxx
entity_id: xxx
domain: binary_sensor
trigger: device
alias: Door closed
id: door_closed
conditions: []
actions:
- choose:
- conditions:
- condition: trigger
id:
- door_left_open
- condition: device
type: is_on
device_id: xxx
entity_id: xxx
domain: switch
sequence:
- alias: Snapshot Aircon State
action: scene.create
metadata: {}
data:
scene_id: snapshot_office_aircon_state
snapshot_entities:
- switch.office_aircon_power
- type: turn_off
device_id: xxx
entity_id: xxx
domain: switch
alias: Aircon is on and door is left open
- conditions:
- condition: trigger
id:
- door_closed
- condition: template
value_template: "{{ states.scene.snapshot_office_aircon_state != None }}"
alias: Aircon snapshot state exists
sequence:
- action: scene.turn_on
metadata: {}
data: {}
target:
entity_id: scene.snapshot_office_aircon_state
alias: Restore previous aircon state
- action: scene.delete
metadata: {}
data: {}
target:
entity_id: scene.snapshot_office_aircon_state
alias: Delete aircon state snapshot
alias: Aircon was previously turned off and door is closed
mode: queued
max: 10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment