Daylight Harvesting & Motion Sensor
This function implements the functionality of Daylight Harvesting and Motion Sensor. If movement is detected, the luminaires are set to a brightness level corresponding with the current daylight harvesting value. It eliminates lighting “jumps“ while Daylight Harvesting is active and Motion sensor triggers fixed brightness values.
Import the ready made flow using the instructions here: Importing a Node-RED flow or follow the instructions below.
[{"id":"0b8a5fc647e413bf","type":"tab","label":"Flow 6","disabled":false,"info":""},{"id":"036840cb239dc941","type":"vertex daylightHarvesting","z":"0b8a5fc647e413bf","name":"Daylight Harvesting","primarygroup":"1406058a7c624da69532a06ea422ec10","target":"200","tolerance":"2","P":0.25,"I":0.03,"D":0,"min":"0","max":"100","x":650,"y":380,"wires":[["16cd547fbf3855fa","a984b3c3eabbc201"]]},{"id":"16cd547fbf3855fa","type":"vertex action","z":"0b8a5fc647e413bf","name":"","typeButton":"directv","bPayload":{"action":"setbrightnesslog","group":null,"param":0,"priority":"0"},"bState":"","defaultpriority":false,"x":890,"y":380,"wires":[["42888051b6ad7cc2"]]},{"id":"81b94d756b86d1f7","type":"vertex action","z":"0b8a5fc647e413bf","name":"","typeButton":"motionsensor","bPayload":{"PRESENCE":{"action":"setbrightness","group":null,"param":"100","priority":"255"},"TRANSITION":{"action":"setbrightness","group":null,"param":"44","priority":"0"},"NOPRESENCE":{"action":"setbrightness","group":null,"param":"0","priority":"254"}},"bState":"","defaultpriority":true,"x":670,"y":540,"wires":[["9c46ac4c449f04ad"]]},{"id":"42888051b6ad7cc2","type":"vertex cluster","z":"0b8a5fc647e413bf","rate":"50","x":1130,"y":460,"wires":[]},{"id":"5561a6e04af30fb8","type":"dali2devs","z":"0b8a5fc647e413bf","name":"Motion Sensor Instance","uid":"00000003A4214709BC","dali2dev":"0","devStatus":2,"instanceType":3,"dali2t1":"10","dali2t2":"2","mode":"","x":350,"y":540,"wires":[["81b94d756b86d1f7"]]},{"id":"be12216b5a32c545","type":"dali2devs","z":"0b8a5fc647e413bf","name":"Light Sensor Instance","uid":"00000003A4214709BC","dali2dev":"2","devStatus":2,"instanceType":4,"dali2t1":"10","dali2t2":"","mode":"","x":340,"y":380,"wires":[["036840cb239dc941"]]},{"id":"1ca07f415f22305f","type":"comment","z":"0b8a5fc647e413bf","name":"change payload function","info":"","x":870,"y":580,"wires":[]},{"id":"a8b75c1533da3223","type":"comment","z":"0b8a5fc647e413bf","name":"Configure the light sensor","info":"","x":350,"y":340,"wires":[]},{"id":"1202eb5a431c5a7c","type":"comment","z":"0b8a5fc647e413bf","name":"Configure the motion sensor","info":"","x":360,"y":600,"wires":[]},{"id":"9c46ac4c449f04ad","type":"function","z":"0b8a5fc647e413bf","name":"motion flow dhv1","func":"if(msg.topic.includes(\"MOTIONSENSOR/PRESENCE\")||msg.topic.includes(\"MOTIONSENSOR/TRANSITION\"))\n{\n for(var gr in msg.payload.parameter.value)\n {\n\t msg.payload.parameter.value[gr] = flow.get(\"dhv1\");\n }\n return msg;\n}\nreturn msg","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":870,"y":540,"wires":[["42888051b6ad7cc2"]]},{"id":"9b39f4104b63f4fa","type":"comment","z":"0b8a5fc647e413bf","name":"Specify DH parameters","info":"","x":640,"y":340,"wires":[]},{"id":"a984b3c3eabbc201","type":"change","z":"0b8a5fc647e413bf","name":"","rules":[{"t":"set","p":"dhv1","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":890,"y":440,"wires":[[]]}]
Step-by-step instructions
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.
dali2devs x2
Daylight Harvesting
function
vertex action x2
vertex cluster
change
See how to configure the Daylight Harvesting node here → Daylight harvesting.
Go to the change node properties. The configuration is shown below. The node writes flow variable “dhv1“ with msg.payload value coming from the output of Daylight Harvesting node.
3. Go into the function node properties and name it motion flow dhv1. Make sure that the code is as in the screenshot below.
4. Open the lower vertex action node properties. By default all instances are marked which means they are disabled. Enable detection by unchecking the Motion/presence sensor checkbox. Set the mode to motion sensor and set parameters like brightness and transition. Remember to set the correct group.
5. Go to the second vertex action node. Set the mode as a Direct Value and Set brightness (scale logarithmic) as the action. Select the same group as in the Daylight Harvesting node. Enable detection by unchecking the Motion/presence sensor checkbox and set the Priority to 0.
Do not forget to click Done and Deploy!