Created
October 24, 2019 20:21
-
-
Save dale3h/f93f51018cc53a59d2dd7bca349d157c to your computer and use it in GitHub Desktop.
[Node-RED] Controlling Lights with deCONZ and Philips Hue Dimmer
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[{"id":"683f5521.03d7ec","type":"link in","z":"2fe9ea1c.17c506","name":"Master Bedroom Dimmer","links":["29f6fa70.0111d6","ddd0422.a7f81c","d8c78531.f3efb8"],"x":55,"y":400,"wires":[["6f9fb9d2.d630a8"]]},{"id":"98b9b53a.831548","type":"switch","z":"2fe9ea1c.17c506","name":"Philips Hue Dimmer","property":"payload.button_id","propertyType":"msg","rules":[{"t":"eq","v":"1","vt":"str"},{"t":"eq","v":"2","vt":"str"},{"t":"eq","v":"3","vt":"str"},{"t":"eq","v":"4","vt":"str"}],"checkall":"false","repair":false,"outputs":4,"x":460,"y":440,"wires":[["c4451284.bb852"],["d330587c.ec3558"],["94d7b051.17b7e"],["6e72b653.bc8898"]],"outputLabels":["On","Bright","Dim","Off"]},{"id":"c4451284.bb852","type":"switch","z":"2fe9ea1c.17c506","name":"On","property":"payload.button_action","propertyType":"msg","rules":[{"t":"eq","v":"press","vt":"str"},{"t":"eq","v":"hold","vt":"str"},{"t":"eq","v":"release_short","vt":"str"},{"t":"eq","v":"release_long","vt":"str"}],"checkall":"false","repair":false,"outputs":4,"x":710,"y":320,"wires":[["e01eaf7f.7b4ff"],[],[],[]],"info":"Press = ignore\nHold = ?\nRelease Short = on\nRelease Long = ?"},{"id":"d330587c.ec3558","type":"switch","z":"2fe9ea1c.17c506","name":"Bright","property":"payload.button_action","propertyType":"msg","rules":[{"t":"eq","v":"press","vt":"str"},{"t":"eq","v":"hold","vt":"str"},{"t":"eq","v":"release_short","vt":"str"},{"t":"eq","v":"release_long","vt":"str"}],"checkall":"false","repair":false,"outputs":4,"x":710,"y":400,"wires":[["be049d.8f6cfb6"],["be049d.8f6cfb6"],[],[]],"info":"Press = ignore\nHold = one \"step\" brighter\nRelease Short = one \"step\" brighter\nRelease Long = ?"},{"id":"94d7b051.17b7e","type":"switch","z":"2fe9ea1c.17c506","name":"Dim","property":"payload.button_action","propertyType":"msg","rules":[{"t":"eq","v":"press","vt":"str"},{"t":"eq","v":"hold","vt":"str"},{"t":"eq","v":"release_short","vt":"str"},{"t":"eq","v":"release_long","vt":"str"}],"checkall":"false","repair":false,"outputs":4,"x":710,"y":480,"wires":[["b3ad0915.c761a8"],["b3ad0915.c761a8"],[],[]],"info":"Press = ignore\nHold = one \"step\" dimmer\nRelease Short = one \"step\" dimmer\nRelease Long = ?"},{"id":"6e72b653.bc8898","type":"switch","z":"2fe9ea1c.17c506","name":"Off","property":"payload.button_action","propertyType":"msg","rules":[{"t":"eq","v":"press","vt":"str"},{"t":"eq","v":"hold","vt":"str"},{"t":"eq","v":"release_short","vt":"str"},{"t":"eq","v":"release_long","vt":"str"}],"checkall":"false","repair":false,"outputs":4,"x":710,"y":560,"wires":[["71758c60.bad1e4"],[],[],[]],"info":"Press = ignore\nHold = ?\nRelease Short = off\nRelease Long = ?"},{"id":"71758c60.bad1e4","type":"api-call-service","z":"2fe9ea1c.17c506","name":"Turn Off","server":"112c7bd1.251304","version":1,"service_domain":"light","service":"turn_off","entityId":"{{entity.entity_id}}","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":900,"y":560,"wires":[[]]},{"id":"6f9fb9d2.d630a8","type":"api-current-state","z":"2fe9ea1c.17c506","name":"light.master_bedroom","server":"112c7bd1.251304","version":1,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"light.master_bedroom","state_type":"str","state_location":"","override_payload":"none","entity_location":"entity","override_data":"msg","blockInputOverrides":false,"x":200,"y":400,"wires":[["98b9b53a.831548"]]},{"id":"be049d.8f6cfb6","type":"function","z":"2fe9ea1c.17c506","name":"Increase Brightness","func":"const BRIGHTNESS_MIN = 5;\nconst BRIGHTNESS_MAX = 254;\nconst BRIGHTNESS_STEP = Math.floor((BRIGHTNESS_MAX - BRIGHTNESS_MIN) / 6);\n\nlet brightness = parseInt(msg.entity.attributes.brightness);\n\nif (!brightness) {\n brightness = BRIGHTNESS_MAX;\n} else {\n brightness = Math.min(brightness + BRIGHTNESS_STEP, BRIGHTNESS_MAX);\n}\n\nmsg.entity.attributes.brightness = brightness;\n\nreturn msg;","outputs":1,"noerr":0,"x":940,"y":400,"wires":[["56af9f09.3370b"]]},{"id":"b3ad0915.c761a8","type":"function","z":"2fe9ea1c.17c506","name":"Decrease Brightness","func":"const BRIGHTNESS_MIN = 5;\nconst BRIGHTNESS_MAX = 254;\nconst BRIGHTNESS_STEP = Math.floor((BRIGHTNESS_MAX - BRIGHTNESS_MIN) / 6);\n\nlet brightness = parseInt(msg.entity.attributes.brightness);\n\nif (!brightness) {\n brightness = BRIGHTNESS_MIN;\n} else {\n brightness = Math.max(brightness - BRIGHTNESS_STEP, BRIGHTNESS_MIN);\n}\n\nmsg.entity.attributes.brightness = brightness;\n\nreturn msg;","outputs":1,"noerr":0,"x":940,"y":480,"wires":[["5409e4e8.53befc"]]},{"id":"e01eaf7f.7b4ff","type":"switch","z":"2fe9ea1c.17c506","name":"Already On?","property":"entity.state","propertyType":"msg","rules":[{"t":"eq","v":"on","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":920,"y":300,"wires":[["6cb095cf.30b3dc"],["a883b18c.c5177"]],"outputLabels":["On","Not On"]},{"id":"b03e2336.d6425","type":"api-current-state","z":"2fe9ea1c.17c506","name":"light.living_room","server":"112c7bd1.251304","version":1,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"light.living_room","state_type":"str","state_location":"","override_payload":"none","entity_location":"entity","override_data":"msg","blockInputOverrides":false,"x":180,"y":480,"wires":[["98b9b53a.831548"]]},{"id":"b5d7e4b6.19f2f8","type":"link in","z":"2fe9ea1c.17c506","name":"Living Room Dimmer","links":["f1f3e5f2.93aed8","443740b1.15854","715e2586.5e9ccc"],"x":55,"y":480,"wires":[["b03e2336.d6425"]]},{"id":"6cb095cf.30b3dc","type":"api-call-service","z":"2fe9ea1c.17c506","name":"Turn On (Full Bright)","server":"112c7bd1.251304","version":1,"service_domain":"light","service":"turn_on","entityId":"{{entity.entity_id}}","data":"{\"brightness\": 254}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1200,"y":280,"wires":[[]]},{"id":"a883b18c.c5177","type":"api-call-service","z":"2fe9ea1c.17c506","name":"Turn On (Last State)","server":"112c7bd1.251304","version":1,"service_domain":"light","service":"turn_on","entityId":"{{entity.entity_id}}","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1200,"y":320,"wires":[[]]},{"id":"56af9f09.3370b","type":"api-call-service","z":"2fe9ea1c.17c506","name":"Turn On (Increase Brightness)","server":"112c7bd1.251304","version":1,"service_domain":"light","service":"turn_on","entityId":"{{entity.entity_id}}","data":"{\"brightness\": {{entity.attributes.brightness}}}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1230,"y":400,"wires":[[]]},{"id":"5409e4e8.53befc","type":"api-call-service","z":"2fe9ea1c.17c506","name":"Turn On (Decrease Brightness)","server":"112c7bd1.251304","version":1,"service_domain":"light","service":"turn_on","entityId":"{{entity.entity_id}}","data":"{\"brightness\": {{entity.attributes.brightness}}}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1230,"y":480,"wires":[[]]},{"id":"112c7bd1.251304","type":"server","z":"","name":"Home Assistant"}] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment