I am having issues setting up a sequence and would appreciate some help.
I have a hue dimmer and would like to achieve the following:
first press - turn light on 5%
second press - 25%
third press - 45%
fourth press - 65%
fifth press - back to 5%
Then loop through the same percentages with each press: 5,25,45,65,5,25,45,65 etc.....
[{"id":"977bd2ef.a55","type":"function","z":"c560b506.abe4d8","name":"","func":"\nif (msg.count === 1) {\n return{\n payload: {\n \"on\": \"true\",\n \"brightness\": 5\n }\n };\n}\nelse if (msg.count === 2) {\n return{\n payload: {\n \"on\": \"true\",\n \"brightness\": 25\n }\n };\n}\nelse if (msg.count === 3) {\n return{\n payload: {\n \"on\": \"true\",\n \"brightness\": 45\n }\n };\n}\nelse if (msg.count === 4) {\n return{\n payload: {\n \"on\": \"true\",\n \"brightness\": 65\n }\n };\n}\nelse if (msg.count === 5) {\n return [ null, msg ];\n}","outputs":2,"noerr":0,"x":770,"y":500,"wires":[["c616a5f1.4cb638","956fddf.ee8872"],["666c319c.573ca","2838a1c3.11b71e"]]},{"id":"c616a5f1.4cb638","type":"hue-light","z":"c560b506.abe4d8","name":"desk lamp","bridge":"8c5e7db8.8c1fd","lightid":"8","colornamer":true,"skipevents":false,"x":1010,"y":480,"wires":[["4f3a3441.a33abc"]]},{"id":"956fddf.ee8872","type":"debug","z":"c560b506.abe4d8","name":"1","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":990,"y":420,"wires":[]},{"id":"aefb6e90.bdb25","type":"inject","z":"c560b506.abe4d8","name":"reset","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"x":510,"y":600,"wires":[["2838a1c3.11b71e"]]},{"id":"e456a128.e2117","type":"counter","z":"c560b506.abe4d8","name":"","init":"0","step":1,"lower":"","upper":"","mode":"increment","outputs":1,"x":620,"y":500,"wires":[["977bd2ef.a55"]]},{"id":"3eb509df.7c9f26","type":"inject","z":"c560b506.abe4d8","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":"","x":440,"y":500,"wires":[["e456a128.e2117"]]},{"id":"666c319c.573ca","type":"debug","z":"c560b506.abe4d8","name":"2","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":970,"y":560,"wires":[]},{"id":"5315be88.f89dc","type":"inject","z":"c560b506.abe4d8","name":"off","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":"","x":650,"y":420,"wires":[["d3369016.bd819"]]},{"id":"d3369016.bd819","type":"change","z":"c560b506.abe4d8","name":"off","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\"on\":false}","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":790,"y":420,"wires":[["c616a5f1.4cb638"]]},{"id":"2838a1c3.11b71e","type":"change","z":"c560b506.abe4d8","name":"","rules":[{"t":"set","p":"payload.brightness","pt":"msg","to":"5","tot":"str"},{"t":"set","p":"reset","pt":"msg","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":720,"y":600,"wires":[["e456a128.e2117","c616a5f1.4cb638","9aad63b.f35b9a"]]},{"id":"9aad63b.f35b9a","type":"debug","z":"c560b506.abe4d8","name":"rules","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":970,"y":620,"wires":[]},{"id":"4f3a3441.a33abc","type":"debug","z":"c560b506.abe4d8","name":"lamp","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":1190,"y":480,"wires":[]},{"id":"8c5e7db8.8c1fd","type":"hue-bridge","z":"","name":"Philips hue","bridge":"192.168.1.120","key":"XtlsvGPtH9Z9O41tqByhqviDaR1yArK8OHhLLpVL","interval":"3000","disableupdates":false}]
With the code above, I get the following:
first press - turn light on 5%
second press - 25%
third press - 45%
fourth press - 65%
fifth press - NOTHING
sixth press - back to 5%
then it loops as desired apart from the nothing every fifth press.
Thanks in advacne.