Sensor with Day/Night scenes

Some sites may require a different lighting system for night and day. The following example shows how to create a logic in Node-Red that switches the scenes with the light scheduler.

Import the ready made flow using the instructions here: or follow the instructions below.

[{"id":"c20b0464.198388","type":"tab","label":"Flow 3","disabled":false,"info":""},{"id":"3bb730d1.f5e56","type":"vertex action","z":"c20b0464.198388","name":"Day","typeButton":"motionsensor","bPayload":{"PRESENCE":{"action":"recallscene","group":"723d2086-8e05-422a-8281-1f0ba2bba854","param":"0","priority":"255"},"TRANSITION":{"action":"recallscene","group":"723d2086-8e05-422a-8281-1f0ba2bba854","param":"1","priority":"0"},"NOPRESENCE":{"action":"recallscene","group":"723d2086-8e05-422a-8281-1f0ba2bba854","param":"4","priority":"254"}},"bState":"","defaultpriority":true,"x":420,"y":320,"wires":[["23df4890.cb08c8","c401ab7a.d09bf8"]]},{"id":"5472207.493a9e","type":"dali2devs","z":"c20b0464.198388","name":"Motion Sensor no1","uid":"00A9D26844F276423D","dali2dev":"0","devStatus":2,"instanceType":3,"dali2t1":"10","dali2t2":"5","instanceData":{"InstanceStatusFlags":2,"InstanceType":3,"Resolution":2,"InstanceError":false,"InstanceActive":true,"InstanceGroup0":255,"InstanceGroup1":255,"InstanceGroup2":255,"EventScheme":2,"EventPriority":4,"EventFilter":3,"EventFilterSize":1,"FeatureType":[],"InputValue":255,"InstanceValue":255,"InstanceDetails":{"DeadtimeTimer":2,"HoldTimer":1,"ReportTimer":20,"Catching":0,"InstanceActive":true},"DataModelRecipe":["Dali2Instance303_config"],"INSTNR":0},"mode":"","x":150,"y":280,"wires":[["3bb730d1.f5e56","dd8a4212.a4b9d"]]},{"id":"587bcccd.bf06f4","type":"dali2devs","z":"c20b0464.198388","name":"Motion Sensor no2","uid":"00AC3809349833D9D5","dali2dev":"0","devStatus":2,"instanceType":3,"dali2t1":"10","dali2t2":"5","instanceData":{"InstanceStatusFlags":2,"InstanceType":3,"Resolution":2,"InstanceError":false,"InstanceActive":true,"InstanceGroup0":255,"InstanceGroup1":255,"InstanceGroup2":255,"EventScheme":2,"EventPriority":4,"EventFilter":3,"EventFilterSize":1,"FeatureType":[],"InputValue":170,"InstanceValue":170,"InstanceDetails":{"DeadtimeTimer":2,"HoldTimer":1,"ReportTimer":20,"Catching":0,"InstanceActive":true},"DataModelRecipe":["Dali2Instance303_config"],"INSTNR":0},"mode":"","x":150,"y":360,"wires":[["3bb730d1.f5e56","dd8a4212.a4b9d"]]},{"id":"1519e891.3537b7","type":"dali2devs","z":"c20b0464.198388","name":"Motion Sensor no3","uid":"008D016096DBB94D2E","dali2dev":"0","devStatus":2,"instanceType":3,"dali2t1":"10","dali2t2":"5","instanceData":{"InstanceStatusFlags":2,"InstanceType":3,"Resolution":2,"InstanceError":false,"InstanceActive":true,"InstanceGroup0":255,"InstanceGroup1":255,"InstanceGroup2":255,"EventScheme":2,"EventPriority":4,"EventFilter":3,"EventFilterSize":1,"FeatureType":[],"InputValue":0,"InstanceValue":0,"InstanceDetails":{"DeadtimeTimer":0,"HoldTimer":1,"ReportTimer":254,"Catching":0,"InstanceActive":true},"DataModelRecipe":["Dali2Instance303_config"],"INSTNR":0},"mode":"","x":150,"y":440,"wires":[["3bb730d1.f5e56","dd8a4212.a4b9d"]]},{"id":"7483d7d7.881e18","type":"light-scheduler","z":"c20b0464.198388","settings":"b17a207d2a6309f3","events":"[{\"start\":{\"dow\":2,\"mod\":570},\"end\":{\"dow\":2,\"mod\":1020}},{\"start\":{\"dow\":1,\"mod\":570},\"end\":{\"dow\":1,\"mod\":1020}},{\"start\":{\"dow\":3,\"mod\":570},\"end\":{\"dow\":3,\"mod\":1020}},{\"start\":{\"dow\":5,\"mod\":570},\"end\":{\"dow\":5,\"mod\":1020}},{\"start\":{\"dow\":6,\"mod\":570},\"end\":{\"dow\":6,\"mod\":1020}},{\"start\":{\"dow\":0,\"mod\":570},\"end\":{\"dow\":0,\"mod\":1020}},{\"start\":{\"dow\":4,\"mod\":570},\"end\":{\"dow\":4,\"mod\":1020}}]","topic":"day/night","name":"Scheduler","onPayload":"true","onPayloadType":"bool","offPayload":"false","offPayloadType":"bool","onlyWhenDark":false,"scheduleRndMax":"","sunElevationThreshold":6,"sunShowElevationInStatus":false,"outputfreq":"output.statechange.startup","x":100,"y":140,"wires":[["ee9a16d9.f48b58"]]},{"id":"b5bed2b1.8797","type":"change","z":"c20b0464.198388","name":"Daylight","rules":[{"t":"set","p":"daylight","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":440,"y":140,"wires":[["484fa6fa.9eb638"]]},{"id":"23df4890.cb08c8","type":"switch","z":"c20b0464.198388","name":"Daylight is true","property":"daylight","propertyType":"flow","rules":[{"t":"true"}],"checkall":"true","repair":false,"outputs":1,"x":760,"y":320,"wires":[["80a1938.10d1d7"]]},{"id":"80a1938.10d1d7","type":"vertex cluster","z":"c20b0464.198388","rate":90,"x":1010,"y":320,"wires":[]},{"id":"f74523e5.6c7a2","type":"switch","z":"c20b0464.198388","name":"Daylight is false","property":"daylight","propertyType":"flow","rules":[{"t":"false"}],"checkall":"true","repair":false,"outputs":1,"x":760,"y":400,"wires":[["80a1938.10d1d7"]]},{"id":"bbc049ed.4253b8","type":"inject","z":"c20b0464.198388","name":"enable","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":"","topic":"","payload":"true","payloadType":"bool","x":290,"y":80,"wires":[["b5bed2b1.8797"]]},{"id":"56e04733.f09cb8","type":"inject","z":"c20b0464.198388","name":"disable","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":true,"onceDelay":"","topic":"","payload":"false","payloadType":"bool","x":280,"y":200,"wires":[["b5bed2b1.8797"]]},{"id":"dd8a4212.a4b9d","type":"vertex action","z":"c20b0464.198388","name":"Night","typeButton":"motionsensor","bPayload":{"PRESENCE":{"action":"recallscene","group":"723d2086-8e05-422a-8281-1f0ba2bba854","param":"2","priority":"255"},"TRANSITION":{"action":"recallscene","group":"723d2086-8e05-422a-8281-1f0ba2bba854","param":"3","priority":"0"},"NOPRESENCE":{"action":"recallscene","group":"723d2086-8e05-422a-8281-1f0ba2bba854","param":"4","priority":"254"}},"bState":"","defaultpriority":true,"x":420,"y":400,"wires":[["f74523e5.6c7a2","28c39d17.106fe2"]]},{"id":"28c39d17.106fe2","type":"change","z":"c20b0464.198388","name":"night","rules":[{"t":"set","p":"night","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":590,"y":460,"wires":[[]]},{"id":"c401ab7a.d09bf8","type":"change","z":"c20b0464.198388","name":"day","rules":[{"t":"set","p":"day","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":590,"y":260,"wires":[[]]},{"id":"b619e71d.d7a0b8","type":"comment","z":"c20b0464.198388","name":"Check if day/night","info":"","x":110,"y":80,"wires":[]},{"id":"8b3522d7.0e088","type":"comment","z":"c20b0464.198388","name":"Sensors","info":"","x":120,"y":500,"wires":[]},{"id":"ee9a16d9.f48b58","type":"vertex filterByVertex","z":"c20b0464.198388","selectedVertex":"10.0.6.51","x":270,"y":140,"wires":[["b5bed2b1.8797"]]},{"id":"484fa6fa.9eb638","type":"switch","z":"c20b0464.198388","name":"","property":"payload","propertyType":"msg","rules":[{"t":"cont","v":"true","vt":"str"},{"t":"cont","v":"false","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":590,"y":140,"wires":[["68695eeb.59ae6"],["2e807fb4.6c9f9"]]},{"id":"68695eeb.59ae6","type":"change","z":"c20b0464.198388","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"day","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":760,"y":120,"wires":[["80a1938.10d1d7"]]},{"id":"2e807fb4.6c9f9","type":"change","z":"c20b0464.198388","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"night","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":760,"y":160,"wires":[["80a1938.10d1d7"]]},{"id":"278ed603.85bbca","type":"comment","z":"c20b0464.198388","name":"1) Set true/false to payload","info":"","x":490,"y":100,"wires":[]},{"id":"2fa3814b.fc71ae","type":"comment","z":"c20b0464.198388","name":"2) If payload contains true/false","info":"","x":550,"y":180,"wires":[]},{"id":"ebced9a8.7be148","type":"comment","z":"c20b0464.198388","name":"3) then assign it to the \"day\"/\"night\" variable ","info":"","x":850,"y":80,"wires":[]},{"id":"36c2a6e4.509e1a","type":"comment","z":"c20b0464.198388","name":"day/night variables contain last state of sensor","info":"","x":590,"y":500,"wires":[]},{"id":"65d54920.db05f8","type":"comment","z":"c20b0464.198388","name":"Switching day/night","info":"","x":770,"y":360,"wires":[]},{"id":"b17a207d2a6309f3","type":"light-scheduler-settings","name":"test","latitude":"50.049272","longitude":"19.957367"}]

 

image-20240415-093235.png

Enable and disable inject nodes is used in this flow for manual switching daylight variable directly in NodeRed

DALI2 Devs node sets VA nodes to presence transition or no presence state. Switch nodes next to VA nodes push forward payload message depending on variable generated by Light Scheduler node. If the state of the scheduler were to change, all sensors would have to change their states to switch between VA node actions. This would be very impractical. Therefore, day and night change blocks take the new state of VA. Light scheduler sends day/night variable to vertex cluster when it's change.

Light Scheduler sends it’s message on every vertex in cluster. When there is lot of vertexes on site it could cause heavy traffic on dali bus. So in this situation remember to use Filter by Vertex node. It will limit message from scheduler to one vertex.

Step-by-step instructions

  1. Find the following nodes in the palette on the left side of the Node-RED, drag them to your workspace and connect them as shown.

  • DALI2 Devs

  • vertex action

  • change node

  • switch node

  • Light Scheduler

  • Filter by Vertex

  • vertex cluster

image-20240415-094658.png

 

  1. Edit the DALI2 Devs nodes. In the Serial Number field [1] pick your sensors. Then make sure that checkbox at Dali2 Device 1.Motion/presence sensor is checked [2]. Set the value of presence and transition time [3] and select Occupied and Vacant events like in this screen bellow [4].

 

 

  1. In vertex action nodes select Motion sensor at Mode field [5]. Select group [6] and then at Action, Transition and No presence fields select action Recall scene and then select your scenes.

 

  1. Connect change nodes into vertex actions nodes and set variables like on this screenshot [7].

 

 

  1. Open Light Scheduler settings and configure like in this article .

  2. When it’s lot of vertexes on site use Filter by Vertex.

  3. To Filter by Vertex connect Change node and configure like in this picture [8].

 

  1. Add switch and change configuration as below [9].

 

  1. And change node and configure for day [10] and night [11].

 

  1. Click deploy.