This is a blueprint to get two door sensors to operate a light inside a wardrobe. Opening either door turns on the light, and when both doors close the light turns off.
The light also turns off after a user configurable delay after opening.
This blueprint expects two door sensors and a light entity. I’ve found that a generic “Opening” window can be set to be a door sensor.
blueprint:
name: Wardrobe Light Switches
description: Turn on a light inside your wardrobe if one of two switches are Open
domain: automation
input:
door_sensor_1:
name: Door Sensor 1
description: This sensor is on the first door
selector:
entity:
domain: binary_sensor
device_class: door
door_sensor_2:
name: Door Sensor 2
description: This sensor is on the second door
selector:
entity:
domain: binary_sensor
device_class: door
wardrobe_light:
name: Wardrobe Light
description: This is the light inside your wardrobe
selector:
target:
entity:
domain: light
auto_off_delay:
name: Auto Off Delay
description: Delay before the wardrobe powers off automatically
default: 0
selector:
number:
min: 0
max: 86400
unit_of_measurement: seconds
trigger:
- platform: state
entity_id:
- !input door_sensor_1
- !input door_sensor_2
from: "off"
to: "on"
- platform: state
entity_id:
- !input door_sensor_1
- !input door_sensor_2
from: "on"
to: "off"
action:
- alias: "Act depending on door state"
choose:
- conditions:
- alias: "If door 1 is open"
condition: state
entity_id:
- !input door_sensor_1
state: "on"
sequence:
- service: light.turn_on
target: !input wardrobe_light
- delay:
seconds: !input auto_off_delay
- service: light.turn_off
target: !input wardrobe_light
- conditions:
- alias: "If door 2 is open"
condition: state
entity_id:
- !input door_sensor_2
state: "on"
sequence:
- service: light.turn_on
target: !input wardrobe_light
- delay:
seconds: !input auto_off_delay
- service: light.turn_off
target: !input wardrobe_light
- conditions:
- alias: "If both doors now closed"
condition: state
entity_id:
- !input door_sensor_1
- !input door_sensor_2
state: "off"
sequence:
- service: light.turn_off
target: !input wardrobe_light