[{"id":"ea8be161.59f37","type":"tab","label":"Lounge LEDs","disabled":false,"info":""},{"id":"6a39c1fa.20149","type":"function","z":"ea8be161.59f37","name":"","func":"// -----------------------------------------\n// TASMOTA DIMMING\n// Set dimming functions for a dimmable light\n// controlled from another tasmota button\n// allowing for single/double/triple press\n// and inbuilt tasmota dimming\n// -----------------------------------------\n//\n// DIMMING DEVICE tasmota setup commands\n// SetOption68 1 - Sets individual dimmer channels for each PWM (i.e. not RGB)\n// Fade 1 - use inbuilt fader - default is 0\n// DimmerRange (3,100) - set range of dimming\n// Speed 10 - Set facer speed, 1-40 where 1 is fast\n// Speed2 5 - as per speed, but don't store settings\n// \n// BUTTON DEVICE tasmota setup commands\n// SetOption73\tDetach buttons from relays and send multi-press and hold MQTT messages instead\n\n\n// The input message is the MQTT message from the device\n// once setOption73 is set to just check presses and \n// decouple relays.\nvar button = msg.payload.Button1.Action; // SINGLE, DOUBLE, TRIPLE, HOLD\n\n// store local context variable for toggling. We ALWAYS want\n// second single press to ramp light off.\nvar lightStatus = context.get(\"lightStatus\") || [0];\n\n// store a different speed for dimming as we want\n// domming to off to be slightly quicker\n// Tasmota has the Speed2 command for one off changes\nvar fastSpeed = 5 ; \nmsg2 = { payload: fastSpeed };\n\nswitch(button) {\n case \"SINGLE\":\n if (lightStatus == 0) {\n msg.payload = 95 ;\n context.set(\"lightStatus\", 1);\n }\n else {\n msg.payload = 0 ;\n node.send([null,msg2]) ; // This makes turning off dim at fastSpeed\n context.set(\"lightStatus\", 0) ;\n }\n break;\n case \"DOUBLE\":\n msg.payload = 40 ;\n context.set(\"lightStatus\", 1);\n break;\n case \"TRIPLE\":\n msg.payload = 15 ;\n context.set(\"lightStatus\", 1);\n break;\n case \"HOLD\":\n // do nothing\n break;\n default:\n msg.payload = 0 ;\n context.set(\"lightStatus\", 0);\n}\n\nreturn [msg,null];","outputs":2,"noerr":0,"initialize":"","finalize":"","libs":[],"x":300,"y":160,"wires":[["10cee548.f3d6cb","6e9ca988.5f20c8","739c713a.75fe4"],["665b69b0.05fa78","a8a994b2.323898"]]},{"id":"a46f8268.1cacb","type":"debug","z":"ea8be161.59f37","name":"","active":false,"tosidebar":true,"console":true,"tostatus":true,"complete":"payload.Button1.Action","targetType":"jsonata","statusVal":"payload","statusType":"auto","x":310,"y":100,"wires":[]},{"id":"4f0165c4.356afc","type":"mqtt in","z":"ea8be161.59f37","name":"Lounge Light Switch","topic":"stat/tasmo-ks811d-2552-lounge-2/RESULT","qos":"0","datatype":"json","broker":"e28b763a.77bd98","nl":false,"rap":false,"x":110,"y":160,"wires":[["a46f8268.1cacb","6a39c1fa.20149"]]},{"id":"10cee548.f3d6cb","type":"mqtt out","z":"ea8be161.59f37","name":"","topic":"cmnd/tasmo-H801-loungeled1-6180/channel1","qos":"0","retain":"false","respTopic":"","contentType":"","userProps":"","correl":"","expiry":"","broker":"e28b763a.77bd98","x":620,"y":120,"wires":[]},{"id":"6e9ca988.5f20c8","type":"mqtt out","z":"ea8be161.59f37","name":"","topic":"cmnd/tasmo-H801-loungeled1-6180/channel2","qos":"0","retain":"false","respTopic":"","contentType":"","userProps":"","correl":"","expiry":"","broker":"e28b763a.77bd98","x":620,"y":180,"wires":[]},{"id":"665b69b0.05fa78","type":"mqtt out","z":"ea8be161.59f37","name":"","topic":"cmnd/tasmo-H801-loungeled1-6180/Speed2","qos":"0","retain":"false","respTopic":"","contentType":"","userProps":"","correl":"","expiry":"","broker":"e28b763a.77bd98","x":610,"y":240,"wires":[]},{"id":"739c713a.75fe4","type":"debug","z":"ea8be161.59f37","name":"","active":true,"tosidebar":true,"console":true,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":520,"y":60,"wires":[]},{"id":"a8a994b2.323898","type":"debug","z":"ea8be161.59f37","name":"","active":true,"tosidebar":true,"console":true,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":520,"y":320,"wires":[]},{"id":"e28b763a.77bd98","type":"mqtt-broker","name":"Panda","broker":"192.168.3.200","port":"1883","clientid":"","usetls":false,"compatmode":false,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""}]