Hello everyone, I’m new to automations.
My issue: In my living room, I have a Sonoff module connected to a switch that controls a bulb. The bulb is automated to turn on and off via a Sonoff motion sensor.
The automation works well: the light turns on when motion is detected and turns off otherwise.
However, I would like to prevent the automation from restarting if motion is already detected and someone presses the same physical button. But I want it to reactivate again if the room is empty.
Is it possible to configure the system to detect if the room is already occupied when the button is pressed and, in that case, disable the automation and reactivate it again if the room becomes empty?
Can this be done without adding another Zigbee button?
To summarize: I’m in the living room, I turn off the light because I don’t want it on, and I don’t want it to turn back on immediately afterward.
Thanks in advance
Attached is the automation I have and the YAML code.
alias: Allumer 2 lampions salons
description: ""
triggers:
- trigger: state
entity_id:
- binary_sensor.capteur_presence_salon_occupancy
conditions: []
actions:
- choose:
- conditions:
- type: is_occupied
condition: device
device_id: 82ab4758c127dc697bab80f24bcd0b65
entity_id: f8f95be72ff020dadf289a40c288d77b
domain: binary_sensor
sequence:
- type: turn_on
device_id: 730d9cd6be4109887edd4aa70bf02087
entity_id: 397b51739a5c10c6a722739bbebd0ebc
domain: switch
- conditions:
- type: is_not_occupied
condition: device
device_id: 82ab4758c127dc697bab80f24bcd0b65
entity_id: f8f95be72ff020dadf289a40c288d77b
domain: binary_sensor
sequence:
- type: turn_off
device_id: 730d9cd6be4109887edd4aa70bf02087
entity_id: 397b51739a5c10c6a722739bbebd0ebc
domain: switch
mode: single