Light Activation via Motion Sensor Rules

Happy Easter Everyone :slight_smile:

Debian GNU/Linux 10 (buster)
Linux 5.10.17-v8+
Raspberry Pi 4 Model B Rev 1.4
Openhabian 3.0.1

Within the easter break i have received lots of new sonoff zigbee sensors, i have successfully connected them all to the sonoff zigbee bridge running tasmota to mqtt.

Im trying to create a rule to turn a light on when motion is detected but only if night_state = ON. i then want to start a timer for say 5 minutes and then turn off said light if there is no motion. If there is motion detected once the 5 minutes is up, the timer should be reset.

Any input is much appreciated.

This is a very common thing that we start with when we do home automation. It is unfortunate that each of us has to do the same thing again and again. Reusable sets of rule would be useful here, but unfortunately that is still far away due to the low level of abstractions in OpenHab. The general idea is to combine the Astro sensor, motion sensor, timer, and the light switches.

If you search the forum, you will see many solutions. I myself went through 3 iterations.

  1. A HABApp based Python3 solution (more reusable): zone-apis/ at master 路 yfaway/zone-apis 路 GitHub
  2. A Jython based solution: openhab-rules/ at master 路 yfaway/openhab-rules 路 GitHub
  3. An Xtend solution: openhab-rules/lights.rules at master 路 yfaway/openhab-rules 路 GitHub

I have actually just stumbled across this video by a community poster.it鈥檚 perfect for what I want to do .