Hello,
I’m using door sensors to turn on some lights in the room when a wardrobe is opened.
When the wardrobe is closed again, I’d like to restore the lights to their previous state.
In my “Wardrobe opened” automation, I do the following:
alias: Wardrobe opened
trigger:
- type: opened
platform: device
device_id: e33b267c65678fe7f5421ee4f22f6e6c
entity_id: binary_sensor.wardrobe_contact
domain: binary_sensor
condition:
- condition: device
type: is_off
device_id: ef03e478d20e5377e210fe532a0a6bf6
entity_id: light.bedroom_light_1
domain: light
action:
- service: scene.create
data:
scene_id: bedroom_light_1_before_wardrobe_is_opened
snapshot_entities:
- light.bedroom_light_1
- if:
- condition: time
before: "07:59:59"
after: "22:00:00"
then:
- service: scene.turn_on
target:
entity_id: scene.wardrobe_illumination_nighttime
metadata: {}
else:
- service: scene.turn_on
target:
entity_id: scene.wardrobe_illumination_daytime
metadata: {}
mode: single
Notice how I’m creating a scene and taking a shapshot of the light.
When the wardrobe gets closed, I run the following automation:
alias: Wardrobe closed
trigger:
- type: not_opened
platform: device
device_id: e33b267c65678fe7f5421ee4f22f6e6c
entity_id: binary_sensor.wardrobe_contact
domain: binary_sensor
action:
- service: scene.turn_on
data: {}
target:
entity_id: scene.bedroom_light_1_before_wardrobe_is_opened
mode: single
The expected behavior is:
- If
light.bedroom_light_1
is off, and you open then close the wardrobe door,light.bedroom_light_1
goes back to off - If
light.bedroom_light_1
is on, and you open the wardrobe door, nothing happens. When you then close it, nothing happens again
However, the actual behavios is:
- Regarless of the previous state of
light.bedroom_light_1
, when the wardrobe door gets closed, the ligth is turned off.
I assume that scene.create
is not storing the snapshot correctly.
How can I debug this, or can anyone see something wrong in my YAML?
Thanks!