Hi,
I have a presence sensor in my office (Combination PIR + mmWave), single entity.
I’d like my office lights to return to their last known state when I enter the room. Upon leaving, they should re-save their state.
I have different scenes for my Office for when I’m Gaming, versus getting work done… so the state of my lights varies when I leave the Office.
Here’s what I have so far…
alias: Office Occupancy
description: ""
trigger:
- platform: state
entity_id:
- binary_sensor.office_occupancy
condition: []
action:
- choose:
- conditions:
- condition: state
entity_id: binary_sensor.office_occupancy
state: "off"
for:
hours: 0
minutes: 0
seconds: 0
sequence:
- service: scene.create
data:
scene_id: automated_office_state_lights
snapshot_entities: >-
light.office_main_lights light.office_floor_lamp
light.office_table_lamp
- service: light.turn_off
data: {}
target:
entity_id:
- light.office_main_lights
- light.office_floor_lamp
- light.office_table_lamp
- conditions:
- condition: state
entity_id: binary_sensor.office_occupancy
state: "on"
sequence:
- service: scene.turn_on
data: {}
target:
entity_id: >-
{% if states.scene.automated_office_state_lights.state is defined %}
scene.automated_office_state_lights
{% else %}
scene.office_working
{% endif %}
default: []
mode: single
Have I got this right? Is there a better approach I’m missing?
Thanks!