# Troubleshooting a specific flow to mimic philips hue, or make a better way to do it?

**URL:** <https://discourse.nodered.org/t/troubleshooting-a-specific-flow-to-mimic-philips-hue-or-make-a-better-way-to-do-it/63560>\
**Category:** General\
**Created:** [7 June 2022 10:05 UTC](https://discourse.nodered.org/t/troubleshooting-a-specific-flow-to-mimic-philips-hue-or-make-a-better-way-to-do-it/63560 "2022-06-07T10:05:56Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![dfxzgli](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dfxzgli/32/62754_2.png) [@dfxzgli](https://discourse.nodered.org/u/dfxzgli)\
**Post date:** [7 June 2022 10:05 UTC](https://discourse.nodered.org/t/troubleshooting-a-specific-flow-to-mimic-philips-hue-or-make-a-better-way-to-do-it/63560/1 "2022-06-07T10:05:56Z")

</div>

I have a flow that i want to mimic Philips hue

Motion detected - \> Turn lights on full  
wait 5 mins for no motion  
Dim lights  
wait 2 mins  
turn off lights

if motion is detected again at any stage it start back at motion detected full brightness,

Now this works mostly, but its flakey and sometimes its doesn't go back to motion detected and full brightness, any ideas?

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/e/c/ec6d78803c8277befbb6552ddedbcf6d3b3189d3.png)

---

<div class="post-metadata">

**Author:** ![Frida](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/frida/32/68250_2.png) [@Frida](https://discourse.nodered.org/u/Frida)\
**Post date:** [25 June 2022 17:59 UTC](https://discourse.nodered.org/t/troubleshooting-a-specific-flow-to-mimic-philips-hue-or-make-a-better-way-to-do-it/63560/2 "2022-06-25T17:59:23Z")

</div>

What type of pir sensor do you use, one that gives a pulse every time there is movement, or one that has a built-in time delay?

---

<div class="post-metadata">

**Author:** ![dfxzgli](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dfxzgli/32/62754_2.png) [@dfxzgli](https://discourse.nodered.org/u/dfxzgli)\
**Post date:** [25 June 2022 18:27 UTC](https://discourse.nodered.org/t/troubleshooting-a-specific-flow-to-mimic-philips-hue-or-make-a-better-way-to-do-it/63560/3 "2022-06-25T18:27:51Z")

</div>

the philips hue indoor sensors that push as soon as motion is detected

---

<div class="post-metadata">

**Author:** ![Frida](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/frida/32/68250_2.png) [@Frida](https://discourse.nodered.org/u/Frida)\
**Post date:** [25 June 2022 19:06 UTC](https://discourse.nodered.org/t/troubleshooting-a-specific-flow-to-mimic-philips-hue-or-make-a-better-way-to-do-it/63560/4 "2022-06-25T19:06:49Z")

</div>

![billede_2022-06-25_205819289](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/1/31c47bc6457e0dcad5145772d4ab8341dd8ec861.png)

```auto
[{"id":"260e8ac429d0545f","type":"inject","z":"38412910c32a18b1","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"on","payloadType":"str","x":110,"y":480,"wires":[["9a277257f84c649d"]]},{"id":"9a277257f84c649d","type":"function","z":"38412910c32a18b1","name":"function 13","func":"let msg1 = {}\nlet msg2 = {}\nlet msg3 = {}\nmsg3.reset = ''\n\nlet lux = flow.get('lux')\n\nlet pulse = true // false if pir have timeout\n\nlet invar = msg.payload\nswitch (invar) {\n case 'on':\n msg1.payload = lux\n node.send([msg1, msg3, msg3])\n if(pulse) {\n msg2.payload = 'on'\n node.send([null, msg2, null])\n }\n break\n case 'off':\n if(!pulse) {\n msg2.payload = 'on'\n node.send([null, msg2, null])\n }\n break\n}\n\n","outputs":3,"noerr":0,"initialize":"","finalize":"","libs":[],"x":280,"y":480,"wires":[["ba1fcebbcab40872","e16392bf3f5d81a7"],["278243f9175161ae"],["ac7a68b5e196c905"]]},{"id":"ba1fcebbcab40872","type":"zigbee2mqtt-out","z":"38412910c32a18b1","name":"","server":"389af9cbf5b0a79d","friendly_name":"Krone1 (4058075208421)","device_id":"0xf0d1b8000017513c","command":"brightness","commandType":"z2m_cmd","payload":"payload","payloadType":"msg","optionsValue":"","optionsType":"nothing","x":890,"y":460,"wires":[]},{"id":"278243f9175161ae","type":"delay","z":"38412910c32a18b1","name":"","pauseType":"delay","timeout":"6","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":460,"y":500,"wires":[["ac92ca3490c5d4a5"]]},{"id":"ac7a68b5e196c905","type":"delay","z":"38412910c32a18b1","name":"","pauseType":"delay","timeout":"3","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":460,"y":560,"wires":[["2130ac0e97cc13fd"]]},{"id":"ac92ca3490c5d4a5","type":"function","z":"38412910c32a18b1","name":"function 14","func":"let msg1 = {}\nlet activ = flow.get('activ')\nlet lux = flow.get('lux')\n\nif (activ) {\n msg1.payload = lux / 4\n node.warn(\"lux/4\");\n}\nif (!activ) {\n msg1.payload = lux / 20\n node.warn(\"lux/20\");\n}\nnode.send(msg1);","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":630,"y":500,"wires":[["ba1fcebbcab40872","ac7a68b5e196c905","e16392bf3f5d81a7"]]},{"id":"2130ac0e97cc13fd","type":"function","z":"38412910c32a18b1","name":"function 15","func":"let msg1 = {}\n\nmsg1.payload = 0\nnode.send(msg1);","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":630,"y":560,"wires":[["ba1fcebbcab40872","e16392bf3f5d81a7"]]},{"id":"4fe037caae8f2558","type":"inject","z":"38412910c32a18b1","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"off","payloadType":"str","x":110,"y":520,"wires":[["9a277257f84c649d"]]},{"id":"bcf763031ab16414","type":"inject","z":"38412910c32a18b1","name":"true at 21:00","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"00 21 * * *","once":false,"onceDelay":0.1,"topic":"","payload":"true","payloadType":"bool","x":140,"y":340,"wires":[["5be6ae88718cddbb"]]},{"id":"e65801e6292657cc","type":"inject","z":"38412910c32a18b1","name":"false at 05:00","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"00 05 * * *","once":false,"onceDelay":0.1,"topic":"","payload":"false","payloadType":"bool","x":140,"y":380,"wires":[["5be6ae88718cddbb"]]},{"id":"5be6ae88718cddbb","type":"function","z":"38412910c32a18b1","name":"function 16","func":"let msg1 = {}\nlet activ = flow.get('activ') || false\nlet lux = flow.get('lux') || 50\n\nif (msg.payload === true) {\n activ = true\n node.status({ fill: \"green\", shape: \"ring\", text: \"on\" });\n lux = 100\n}\n\nif (msg.payload === false) {\n activ = false\n node.status({ fill: \"red\", shape: \"ring\", text: \"off\" })\n lux = 50\n}\n\nmsg1.payload = activ\nmsg1.topic = 'control'\nflow.set('activ', activ)\nflow.set('lux', lux)\n\nreturn msg1","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":370,"y":360,"wires":[[]]},{"id":"7b1201567f0b7548","type":"comment","z":"38412910c32a18b1","name":"let pulse = true // false if pir have timeout","info":"","x":380,"y":440,"wires":[]},{"id":"e16392bf3f5d81a7","type":"debug","z":"38412910c32a18b1","name":"debug 8","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":860,"y":400,"wires":[]},{"id":"389af9cbf5b0a79d","type":"zigbee2mqtt-server","name":"","host":"localhost:1883","mqtt_port":"1883","mqtt_username":"","mqtt_password":"","mqtt_qos":"0","tls":"","usetls":false,"base_topic":"zigbee2mqtt"}]

```

In function 16, you set lux high and lux low.  
In function 13, you select whether the pier has a pulse or timeout.  
Right now it is set to true, ie. sends a pulse every time there is movement.  
Insert your own node.

---

<div class="post-metadata">

**Author:** ![dfxzgli](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dfxzgli/32/62754_2.png) [@dfxzgli](https://discourse.nodered.org/u/dfxzgli)\
**Post date:** [26 June 2022 09:54 UTC](https://discourse.nodered.org/t/troubleshooting-a-specific-flow-to-mimic-philips-hue-or-make-a-better-way-to-do-it/63560/5 "2022-06-26T09:54:49Z")

</div>

not sure thats what im looking for. but I really do appreciate you sending it over.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [25 August 2022 09:55 UTC](https://discourse.nodered.org/t/troubleshooting-a-specific-flow-to-mimic-philips-hue-or-make-a-better-way-to-do-it/63560/6 "2022-08-25T09:55:27Z")

</div>

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