Motion detected light with overriding by ZigBee wall switch


I'm looking to automate my lights with motion sensor, but it needs to be overridable from the light switch itself (in case I want to spend more time in the room than the motion sensor timer gives).

The situation looks as following:

  • the light switch is a eWeLink ZB-SW01. Every time I press it, it toggles the lights and this behaviour cannot be changed (i.e. I cannot press the switch and not toggle the lights),
  • the motion sensor is SONOFF SNZB-03,
  • both are connected via Zigbee2MQTT to Home Assistant.

Here's what I want to achieve:

  1. When I enter the room, I want the lights to turn ON and then after 5 minutes turn OFF,
  2. When I enter the room and press the switch on the wall, I want the lights to remain ON until I turn it OFF manually on the wall or from HA panel OR 60 minutes pass by.

Point 1 is really straightforward. But point 2 is more complex: The usual situation will be:

  1. Me entering the room
  2. Motion sensor turns ON the lights
  3. I press the wall switch, so lights are toggled OFF
  4. Node-RED turns the lights ON again

I want to use the HA events: state and call-service nodes, however calling the service to toggle the lights, triggers the events: state node - however, I can differentiate what was the origin of the event by checking the (it's equal to null if I press the switch on the wall).

I do not want to use poll: state nodes, because of efficiency, speed and latency.

I'd prefer not to use HA input_boolean's and keep all the flags/semaphores within Node-RED.

How to do it, the Node-RED way?

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.