I’ve been playing around with ha for about 4 months now and this is probably the most involved over complicated (likely unnecessarily haha) automation I’ve made to date.
Our house is a default toilet door closed scenario but we do have the odd issue with not knowing if it is currently occupied before trying the door handle and freaking out occupants (or is that just me heh)
I wanted to add a zigbee battery light to the door that turns on when the door is triggered twice and turns off once exited. I haven’t got a light yet, haven’t been shopping for it so at this point I was just testing the automation with the toilet button boolean
I made a counter helper with max of 2 step of 1
toilet button boolean(which would normally be the light that turns on) that the toilet occupied boolean helper turns on
So when the closed door gets opened it increases the counter, when closed, increases the counter, counter hits 2 and turns on the occupied boolean which then turns on the light and when exiting if the light is on then instead of increasing the counter, it decreases and when it hits 0 it turns off the occupied boolean which turns off the light (button)
Vid for any interested
alias: Toilet Light
description: ""
triggers:
- trigger: state
entity_id:
- counter.toilet_door_counter
to: "2"
id: counter
- trigger: state
entity_id:
- input_boolean.toilet_occupied
to: "on"
id: occupiedon
- type: opened
device_id: 625eab6c43541a7f5d62ea0000000000
entity_id: 9764fa91e429100d87cff80000000000
domain: binary_sensor
trigger: device
id: dooropen
- type: not_opened
device_id: 625eab6c43541a7f5d620000000000
entity_id: 9764fa91e429100d87cf0000000000
domain: binary_sensor
trigger: device
id: doorclose
- trigger: state
entity_id:
- counter.toilet_door_counter
to: "0"
id: occupiedoff
- trigger: state
entity_id:
- input_boolean.toilet_occupied
to: "off"
id: toiletoccupiedoff
conditions: []
actions:
- choose:
- conditions:
- condition: trigger
id:
- dooropen
- doorclose
- condition: state
entity_id: input_boolean.toilet_occupied
state: "off"
sequence:
- action: counter.increment
metadata: {}
data: {}
target:
entity_id: counter.toilet_door_counter
- conditions:
- condition: trigger
id:
- counter
sequence:
- action: input_boolean.turn_on
target:
entity_id:
- input_boolean.toilet_occupied
data: {}
- conditions:
- condition: trigger
id:
- occupiedon
sequence:
- action: input_boolean.turn_on
metadata: {}
data: {}
target:
entity_id: input_boolean.toiletbutton
- conditions:
- condition: trigger
id:
- occupiedoff
sequence:
- action: input_boolean.turn_off
metadata: {}
data: {}
target:
entity_id: input_boolean.toilet_occupied
- conditions:
- condition: trigger
id:
- dooropen
- doorclose
- condition: state
entity_id: input_boolean.toilet_occupied
state: "on"
sequence:
- action: counter.decrement
target:
entity_id:
- counter.toilet_door_counter
data: {}
- conditions:
- condition: trigger
id:
- toiletoccupiedoff
sequence:
- action: input_boolean.turn_off
metadata: {}
data: {}
target:
entity_id: input_boolean.toiletbutton
mode: single