Dimming using single push button

Hi,
I am a newbie to Node Red and loving it. I am trying to achieve a flow for Tuya Dimmers flashed with Tasmota and working with Homeassistant. I am wanting to use another single pushbutton on a seperate Sonoff device also running Tasmota with a switchmode1 0 with a momentary pushbutton to toggle light on/off with a short press and cycle between dim up to 100% and down to about 10% with long press. The flow I have kind of works (it is a mix of several flows i have found online) but I know there must be a more elegant way of deciding if short press (less than x milliseconds)then send toggle, else pass press push and subsequent release of button to process dimming. Any help would be greatly appreciated.

Thanks

43%20pm|690x275

[{"id":"6060c8b6.1977e","type":"api-current-state","z":"8fc67949.33607","name":"Office Brightness","server":"f33ae2cd.0fa4","version":1,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","override_topic":true,"entity_id":"light.office_light","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":150,"y":500,"wires":[["83302ba.965fdd8"]]},{"id":"69e8c99.022afb8","type":"change","z":"8fc67949.33607","name":"Get Brightness","rules":[{"t":"set","p":"payload","pt":"msg","to":"data.attributes.brightness","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":340,"y":560,"wires":[["d4743cd1.548d"]]},{"id":"49cf06fb.b1e638","type":"function","z":"8fc67949.33607","name":"Add Fib","func":"var iCurr = context.flow.get('iCurr') || 2;\nvar iPrev = context.flow.get('iPrev') || 1;\nvar iFib = context.flow.get('iFib') || 2;\n\nmsg.payload = Math.min(100, msg.payload + iFib);\n\niCurr = iFib;\niFib = iFib + iPrev;\niPrev = iCurr;\n\ncontext.flow.set('iCurr',iCurr);\ncontext.flow.set('iPrev',iPrev);\ncontext.flow.set('iFib',iFib);\n\nif (iCurr == 2){\n    context.flow.set('dCurr',null);\n    context.flow.set('dPrev',null);\n    context.flow.set('dFib',null);\n}\n\nreturn msg;","outputs":1,"noerr":0,"x":920,"y":360,"wires":[["58176016.a7ef9","c293ba8f.64b658"]]},{"id":"d2213fcb.659ac8","type":"server-state-changed","z":"8fc67949.33607","name":"Office Switch State","server":"f33ae2cd.0fa4","version":1,"entityidfilter":"binary_sensor.office_switch","entityidfiltertype":"substring","outputinitially":false,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":false,"x":110,"y":220,"wires":[["fdcd66b3.9e41a","d4de75bd.11a56"]]},{"id":"d4de75bd.11a56","type":"switch","z":"8fc67949.33607","name":"Hold State","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"on","vt":"str"},{"t":"nnull"}],"checkall":"true","repair":false,"outputs":2,"x":150,"y":300,"wires":[["6060c8b6.1977e"],["b2f3b0b3.cc8f2","b1580762.edfe5"]]},{"id":"c5848476.d0628","type":"function","z":"8fc67949.33607","name":"Subtract Fib","func":"var dCurr = context.flow.get('dCurr') || 2;\nvar dPrev = context.flow.get('dPrev') || 1;\nvar dFib = context.flow.get('dFib') || 2;\n\nmsg.payload = Math.max(10, msg.payload - dFib);\n\ndCurr = dFib;\ndFib = dFib + dPrev;\ndPrev = dCurr;\n\ncontext.flow.set('dCurr',dCurr);\ncontext.flow.set('dPrev',dPrev);\ncontext.flow.set('dFib',dFib);\n\nif (dCurr == 2){\n    context.flow.set('iCurr',null);\n    context.flow.set('iPrev',null);\n    context.flow.set('iFib',null);\n}\n\nreturn msg;","outputs":1,"noerr":0,"x":890,"y":300,"wires":[["3ed7284c.f01ff","c293ba8f.64b658"]]},{"id":"ac48a0d5.87cf1","type":"msg-router","z":"8fc67949.33607","routerType":"roundrobin","topicDependent":false,"counterReset":true,"msgKeyField":"payload","undefinedHash":false,"outputsInfo":[{"active":true,"clone":false,"delay":"0","weight":"0"},{"active":true,"clone":false,"delay":"0","weight":"0"}],"name":"Round Robin Router","delaying":"unrelated","msgControl":false,"outputs":2,"x":740,"y":560,"wires":[["49cf06fb.b1e638"],["c5848476.d0628"]]},{"id":"aa22df38.988778","type":"api-call-service","z":"8fc67949.33607","name":"Office Light","server":"f33ae2cd.0fa4","service_domain":"light","service":"turn_on","data":"{\"entity_id\":\"light.office_light\"}","mergecontext":"","output_location":"payload","output_location_type":"msg","mustacheAltTags":false,"x":1330,"y":360,"wires":[[]],"icon":"node-red/light.png"},{"id":"b2f3b0b3.cc8f2","type":"traffic","z":"8fc67949.33607","name":"Break when Stop","property_allow":"payload","filter_allow":"on","ignore_case_allow":false,"negate_allow":false,"send_allow":false,"property_stop":"payload","filter_stop":"off","ignore_case_stop":false,"negate_stop":false,"send_stop":false,"default_start":true,"differ":false,"x":670,"y":260,"wires":[["c5848476.d0628"]]},{"id":"3ed7284c.f01ff","type":"delay","z":"8fc67949.33607","name":"","pauseType":"delay","timeout":"400","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":670,"y":200,"wires":[["b2f3b0b3.cc8f2"]]},{"id":"b1580762.edfe5","type":"traffic","z":"8fc67949.33607","name":"Break when Stop","property_allow":"payload","filter_allow":"on","ignore_case_allow":false,"negate_allow":false,"send_allow":false,"property_stop":"payload","filter_stop":"off","ignore_case_stop":false,"negate_stop":false,"send_stop":false,"default_start":true,"differ":false,"x":670,"y":360,"wires":[["49cf06fb.b1e638"]]},{"id":"58176016.a7ef9","type":"delay","z":"8fc67949.33607","name":"","pauseType":"delay","timeout":"400","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":650,"y":420,"wires":[["b1580762.edfe5"]]},{"id":"d4743cd1.548d","type":"range","z":"8fc67949.33607","minin":"1","maxin":"255","minout":"1","maxout":"100","action":"clamp","round":true,"property":"payload","name":"Brightness %","x":520,"y":560,"wires":[["ac48a0d5.87cf1"]]},{"id":"83302ba.965fdd8","type":"switch","z":"8fc67949.33607","name":"Light On/Off","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"on","vt":"str"},{"t":"eq","v":"off","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":150,"y":560,"wires":[["69e8c99.022afb8"],["e9b0771a.56668"]]},{"id":"e9b0771a.56668","type":"change","z":"8fc67949.33607","name":"Set Brightness","rules":[{"t":"set","p":"payload","pt":"msg","to":"10","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":340,"y":640,"wires":[["3f9bbda3.c02cca"]]},{"id":"3f9bbda3.c02cca","type":"function","z":"8fc67949.33607","name":"Reset Context","func":"context.flow.set('iCurr',null);\ncontext.flow.set('iPrev',null);\ncontext.flow.set('iFib',null);\n\nreturn msg;","outputs":1,"noerr":0,"x":520,"y":640,"wires":[["49cf06fb.b1e638","68a8e294.84651c"]]},{"id":"68a8e294.84651c","type":"change","z":"8fc67949.33607","name":"Reset Router","rules":[{"t":"set","p":"reset","pt":"msg","to":"true","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":690,"y":640,"wires":[["ac48a0d5.87cf1"]]},{"id":"c293ba8f.64b658","type":"function","z":"8fc67949.33607","name":"Brightness Data","func":"newmsg = {};\n\nbrightness = msg.payload;\n\nnewmsg.payload = { data: {\"brightness_pct\":brightness, \"transition\":0.1 }};\n\nreturn newmsg;","outputs":1,"noerr":0,"x":1160,"y":360,"wires":[["aa22df38.988778"]]},{"id":"bdecf56c.911b78","type":"comment","z":"8fc67949.33607","name":"Why not events?","info":"You must use state because \"hold\" is\ncommunicated by the switch being \"on\".\n\nWe capture the release by the state being \"off\".\n\nThe events node lets you capture a\n\"long click\", but not a hold.","x":100,"y":180,"wires":[]},{"id":"55b063ca.037e94","type":"comment","z":"8fc67949.33607","name":"What's happening here?","info":"If the light is on then we capture its\nbrightness attribute thanks to the\noverride payload earlier. Now we set payload\nto brightness.\n\nIf it's off then we set payload (brightness)\nto 1.","x":150,"y":460,"wires":[]},{"id":"ce214ee1.0cb6f8","type":"comment","z":"8fc67949.33607","name":"Reset?","info":"In Add Fib we have variables that allow us to\nincrease in fibonacci increments.\n\nThese variables are set in the node context\nwhich only ever go back to null if we redeploy\nor explicitly say so.\n\nLet's say we just brightened the light, then\nturned it off. The variables will still be set.\n(They are reset when you go through the other\ndirection).\nWe want to start brightening our light with\nsmall increments again, so we nullify the\ncontext.\n\nWe also need to reset the router because if we\ndimmed, then turned off light, it will want to\nbrighten next time. But we *are* brightening\nnow (from off)! So we reset it because next time\nit should dim.","x":530,"y":700,"wires":[]},{"id":"eb4abda1.de66b","type":"comment","z":"8fc67949.33607","name":"Router?","info":"Round Robin.\n\nWe brighten.\nWe dim.\nWe brighten.\nWe dim.\netc.","x":730,"y":520,"wires":[]},{"id":"49eff3d2.ae64fc","type":"comment","z":"8fc67949.33607","name":"Loops?","info":"Both loops work the same.\n\nWe receive the payload with brightness % and then\nstart adding/subtracting fibonacci increments.\n\nThe traffic node allows this loop to continue\nas long as the hold state is \"on\". Once the hold\nstate changes to \"off\" the loop is broken.\n\nEvery 500ms a light.turn_on with a brightness\nand transition option is sent to the light\nspecified, hopefully gracefully brightening\nthe light.\n\nThere is a little Math in the functions to\ninsure that we don't go below 0% or over 100%.","x":670,"y":300,"wires":[]},{"id":"c1670d07.441d88","type":"debug","z":"8fc67949.33607","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":1510,"y":260,"wires":[]},{"id":"b4dea629.3cf7c","type":"switch","z":"8fc67949.33607","name":"Short toggle","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"short","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":790,"y":80,"wires":[["2870c693.ebfbaa"]]},{"id":"2870c693.ebfbaa","type":"change","z":"8fc67949.33607","name":"Toggle","rules":[{"t":"set","p":"payload","pt":"msg","to":"toggle","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":930,"y":80,"wires":[["b1a73ca2.6c77a8"]]},{"id":"fdcd66b3.9e41a","type":"change","z":"8fc67949.33607","name":"Add timestamp","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\t    'state': payload,\t    'timestamp': $millis()\t}","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":140,"y":80,"wires":[["74932ec.17155d"]]},{"id":"74932ec.17155d","type":"join","z":"8fc67949.33607","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"payload.state","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"2","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":290,"y":80,"wires":[["e596acd1.f23bb"]]},{"id":"e1c5e484.53c948","type":"change","z":"8fc67949.33607","name":"Process delta","rules":[{"t":"set","p":"threshold","pt":"msg","to":"400","tot":"num"},{"t":"set","p":"delta","pt":"msg","to":"$lookup(payload, 'off').timestamp - $lookup(payload, 'on').timestamp","tot":"jsonata"},{"t":"set","p":"payload","pt":"msg","to":"delta < threshold ? 'short' : 'long'","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":620,"y":80,"wires":[["b4dea629.3cf7c"]]},{"id":"e596acd1.f23bb","type":"switch","z":"8fc67949.33607","name":"Filter negative","property":"$lookup(payload, 'off').timestamp - $lookup(payload, 'on').timestamp","propertyType":"jsonata","rules":[{"t":"nnull"}],"checkall":"true","repair":false,"outputs":1,"x":440,"y":80,"wires":[["e1c5e484.53c948"]]},{"id":"8f4d0d9a.3086c","type":"api-call-service","z":"8fc67949.33607","name":"Office Light","server":"f33ae2cd.0fa4","service_domain":"light","service":"toggle","data":"{\"entity_id\":\"light.office_light\"}","mergecontext":"","output_location":"payload","output_location_type":"msg","mustacheAltTags":false,"x":1250,"y":80,"wires":[[]],"icon":"node-red/light.png"},{"id":"b1a73ca2.6c77a8","type":"change","z":"8fc67949.33607","name":"Set Brightness","rules":[{"t":"set","p":"payload","pt":"msg","to":"10","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":1080,"y":80,"wires":[["8f4d0d9a.3086c"]]},{"id":"f33ae2cd.0fa4","type":"server","z":"","name":"Home Assistant","legacy":false,"hassio":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":false}]

Hi brettig,
Did you solve this? I am in a kind of similar situation and I cannot make this work the way I want it to..
I have my pushbuttons connected to a PLC and I have programmed this to send up one pulse for single click which then triggers light toggle function, this works fine so I am now trying to get push and hold to dim the lights up and down.

I am using IKEA Trådfri lightbulbs and zigbee2mqtt in home assistant to control these.

First I created a ramp function in the PLC which is starting at the current brightness and then ramping up to 255 and then back down again. I then used a function block in node red to pass that ramp as the brightness, like this:

msg.payload = {
domain: 'light',
service: 'turn_on',
data: { entity_id: 'light.bedroom_bed_right', brightness: msg.payload }
};
return msg;

That was not stable at all, I guess that was because the IKEA lights, the zigbee2mqtt bridge or home assistant was not able to process so many commands so I then tried to send a boolean from the PLC instead and attempted to ramp up and down in node red. I could not get this to work either, I noticed that the

data.new_state.attributes.brightness

Immediately gets set to the new brightness command, not the actual state of the lightbulb. So I cannot use this value to decide when to ramp back down for example.
The way I have this working now is like this:
I get the current brightness from home assistant and send that to the PLC.
Once someone activates the push&hold function I use that value, add (or subract) a number from that and send to node red. I then get the current brightness in node red, add a delay of one second to that and send it back to the PLC. When the PLC sees that the actual brightness = brightness command AND push&hold is still activated I add another number to the actual value and send that as a new command.
And if I reach 255 or 1 I reverse the direction.
And if the push&hold is released at any time the last command is kept.
But this is also unstable, quite often the lightbulb does not want to play along and also the light is not at all smoothly dimmed up and down.
I would very much like to have the actual brightness of the lightbulb as a variable that can be used, I mean a value that is ramped up and down according to the actual light. Not just immediately getting the new setpoint.

Hi,

I kinda got things working ok. My prefered solution that I will be going with is to use a WiFi dimmer controller flashed with Tasmota. There may be other more compact tasmota compatible options out there. This is the one I used

I am using standard dimmable 240v LED Downlights. I am tucking the dimmer controller in behind the wall as I want more compact switch plates with multiple controllers on one plate and prefer the appearance of the switch plates I already have. For the wall controller, I have another sonoff device this time flashed with ESP Easy and using a Rotary encoder (for dimmer operations) with the encoder pushbutton (for toggle on/of).

This works good enough for what I need. The only thing that is not perfect is that ESP Easy does not allow writing the current dimmer value to the encoder. This is only a small issue ie the actual light dimmer value may not match what is stored for the encoder. This quickly rights itself when the dimmer knob is turned and the correct value is always shown for the slider in Homeassistant. It could potentially mean that if the light is on 20% and the dimmer knob has 100% stored turning the dimer knob would see the light then jump to 100% before then following the knob.

I would have prefered to stick with a Tasmota only solution but it seemed like getting Rotary Encoder support going in Tasmota was going to take a steeper learning curve in the source code than I have the time for ATM. If Encoder support was available in Tasmota this could then eliminate the need for the second Sonoff device although to use an encuder with pushbutton requires 3 spare GPIO's. I wanted Tem/Humidity in each room so Im just using Sonoff TH10's with the Sonoff Tem/humidity sensor and there are 3 GPIO's available with a bit of soldering.

I did have a single pushbutton working as a dim up down but I have some legacy visitors at times (my mother) that would require too much of my time to educate in their use I decided to stick with something that is absolutely clear at first glance.

Hope this helps

Brett

Hello,
This was of great interest to me and I've been looking for a "ready-made" solution to do just that for the lights at home, but just did not find it! So I made this using only "standard' nodes. I saw the "one button dimmer" node made by woozar, but wasn't able to install it, too many unresolved dependencies.

I'm definitely not an expert and surely it could use some work, I'm open to any advice!

For now it seems to work a treat for what I wanted, which is:

Short press -> light on
Short press -> light off
Keep pressing -> light comes on (or stays on) and it starts dimming. When it's at the minimum or maximum it reverses direction
Release -> dimming stops, light stays on
Long press again -> starts dimming in the other direction.
Short press -> light off

[{"id":"fec7f67a.46aff8","type":"ui_text","z":"adfd800e.48ad8","group":"e3042201.b26248","order":4,"width":"2","height":"1","name":"","label":"","format":"{{msg.payload}}","layout":"row-spread","x":970,"y":540,"wires":[]},{"id":"93a99bbb.e9243","type":"delay","z":"adfd800e.48ad8","name":"délai x ms","pauseType":"delayv","timeout":"50","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":550,"y":580,"wires":[["f7fcab8b.a0e728"]]},{"id":"f7fcab8b.a0e728","type":"traffic","z":"adfd800e.48ad8","name":"Dimming","property_allow":"traffic","filter_allow":"allow","ignore_case_allow":false,"negate_allow":false,"send_allow":false,"property_stop":"traffic","filter_stop":"stop","ignore_case_stop":false,"negate_stop":false,"send_stop":false,"default_start":false,"differ":false,"x":540,"y":660,"wires":[["4ff64c88.f0eafc"]]},{"id":"4ff64c88.f0eafc","type":"function","z":"adfd800e.48ad8","name":"","func":"node.status({fill:\"blue\",shape:\"dot\",text: (\"Direction: \" + flow.get('dimDirection') + \n                \", Current: \" + flow.get('dimCurrentValue') +\n                \", Max: \" + flow.get('dimMaxValue') +\n                \", Min: \" + flow.get('dimMinValue') +\n                \", Incr.: \" + flow.get('dimIncrement')\n                )});\n\nvar dir = flow.get('dimDirection');\nvar current = flow.get('dimCurrentValue');\nvar max = flow.get('dimMaxValue');\nvar min = flow.get('dimMinValue');\nvar inc = flow.get('dimIncrement');\n\n\n\nif (dir == 1 ) {\n    if (current + inc < max)   {\n        current = current + inc;\n        msg.payload = current;\n    } else {\n        current = max; \n        msg.payload = current;\n        flow.set('dimDirection', 0);\n    }\n} \n\n \nif (dir == 0 ) {\n    if (current - inc > min)   {\n        current = current - inc;\n        msg.payload = current;\n    } else {\n        current = min;\n        msg.payload = current;\n        flow.set('dimDirection', 1);\n    }\n} \n\n\nreturn msg;","outputs":1,"noerr":0,"x":290,"y":580,"wires":[["93a99bbb.e9243","59c368c9.8837b8"]]},{"id":"b1e11036.2e549","type":"function","z":"adfd800e.48ad8","name":"stop","func":"\n\n\n\nflow.set('lightValue', flow.get ('dimCurrentValue'));\n\nmsg.traffic=\"stop\";\n\nreturn msg;","outputs":1,"noerr":0,"x":330,"y":680,"wires":[["f7fcab8b.a0e728"]]},{"id":"822fdc46.91f368","type":"function","z":"adfd800e.48ad8","name":"allow","func":"\nflow.set('dimState', 1);\nflow.set('lightState', 1);\n\n\nmsg.traffic=\"allow\";\n\n\nreturn msg;","outputs":1,"noerr":0,"x":350,"y":640,"wires":[["f7fcab8b.a0e728"]]},{"id":"74cae804.03f81","type":"inject","z":"adfd800e.48ad8","name":"Init dimIncrement","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":true,"onceDelay":0.1,"x":130,"y":100,"wires":[["66f1798.0adff08"]]},{"id":"66f1798.0adff08","type":"function","z":"adfd800e.48ad8","name":"Init dimIncrement","func":"flow.set('dimIncrement', 6);\nreturn msg;","outputs":1,"noerr":0,"x":350,"y":100,"wires":[[]]},{"id":"11bae07b.6a6da8","type":"inject","z":"adfd800e.48ad8","name":"Init dimDirection","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":true,"onceDelay":0.1,"x":130,"y":140,"wires":[["5a55b831.bf99a8"]]},{"id":"5a55b831.bf99a8","type":"function","z":"adfd800e.48ad8","name":"Init dim Direction","func":"flow.set('dimDirection', 1);\nreturn msg;","outputs":1,"noerr":0,"x":350,"y":140,"wires":[[]]},{"id":"22c35776.95a088","type":"inject","z":"adfd800e.48ad8","name":"Init dimMinValue","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":true,"onceDelay":0.1,"x":130,"y":180,"wires":[["3baa887a.b7ebc"]]},{"id":"3baa887a.b7ebc","type":"function","z":"adfd800e.48ad8","name":"Init dimMinValue","func":"flow.set('dimMinValue', 0);\nreturn msg;","outputs":1,"noerr":0,"x":350,"y":180,"wires":[[]]},{"id":"eeddba7f.b8f788","type":"inject","z":"adfd800e.48ad8","name":"Init dimMaxValue","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":true,"onceDelay":0.1,"x":130,"y":220,"wires":[["f767c54f.f12d68"]]},{"id":"f767c54f.f12d68","type":"function","z":"adfd800e.48ad8","name":"Init dimMaxValue","func":"flow.set('dimMaxValue', 255);\nreturn msg;","outputs":1,"noerr":0,"x":350,"y":220,"wires":[[]]},{"id":"22ac5327.be93cc","type":"inject","z":"adfd800e.48ad8","name":"Init dimCurrentValue","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":true,"onceDelay":0.1,"x":140,"y":260,"wires":[["652ee4cc.5e8ffc"]]},{"id":"652ee4cc.5e8ffc","type":"function","z":"adfd800e.48ad8","name":"Init dimCurrentValue","func":"flow.set('dimCurrentValue', 0);\nreturn msg;","outputs":1,"noerr":0,"x":360,"y":260,"wires":[[]]},{"id":"8c70e401.a453c8","type":"function","z":"adfd800e.48ad8","name":"Store current value","func":"node.status({fill:\"blue\",shape:\"dot\",text: (\"Value: \" + msg.payload )});\n\nflow.set('dimCurrentValue', msg.payload);\n\nreturn msg;","outputs":1,"noerr":0,"x":790,"y":540,"wires":[["fec7f67a.46aff8"]]},{"id":"948f65c1.b3d7e8","type":"inject","z":"adfd800e.48ad8","name":"Init delay node","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":true,"onceDelay":"0.3","x":120,"y":480,"wires":[["7e67cf16.d3685"]]},{"id":"7e67cf16.d3685","type":"function","z":"adfd800e.48ad8","name":"Init delay node","func":"node.status({fill:\"green\",shape:\"dot\",text: (\"Delay: \" + flow.get('dimPeriod'))});\n\nmsg.delay = flow.get('dimPeriod');\n\nreturn msg;","outputs":1,"noerr":0,"x":360,"y":480,"wires":[["93a99bbb.e9243"]]},{"id":"23b669c4.cc340e","type":"inject","z":"adfd800e.48ad8","name":"Init dimPeriod","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":true,"onceDelay":0.1,"x":120,"y":300,"wires":[["cba25415.c5ec48"]]},{"id":"cba25415.c5ec48","type":"function","z":"adfd800e.48ad8","name":"Init dimPeriod","func":"// Intervalle de rafraichissement en millisecondes\n\nflow.set('dimPeriod', 10 );\nreturn msg;","outputs":1,"noerr":0,"x":340,"y":300,"wires":[[]]},{"id":"172eb664.6ea192","type":"ui_button","z":"adfd800e.48ad8","name":"STATE DISPLAY","group":"e3042201.b26248","order":20,"width":"6","height":"1","passthru":false,"label":"TEST - {{status}}","color":"WHITE","bgcolor":"{{background}}","icon":"","payload":"","payloadType":"str","topic":"","x":1190,"y":1160,"wires":[[]]},{"id":"82392788.93ec98","type":"change","z":"adfd800e.48ad8","name":"BLACK","rules":[{"t":"set","p":"background","pt":"msg","to":"BLACK","tot":"str"},{"t":"set","p":"status","pt":"msg","to":"OFF","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1000,"y":1100,"wires":[["172eb664.6ea192","c567fdd3.1d763"]]},{"id":"3d884590.e903ba","type":"change","z":"adfd800e.48ad8","name":"RED","rules":[{"t":"set","p":"background","pt":"msg","to":"RED","tot":"str"},{"t":"set","p":"status","pt":"msg","to":"ON","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1010,"y":1060,"wires":[["172eb664.6ea192","ec9dcb49.bdec18"]]},{"id":"7d64ba32.f40b8c","type":"ui_template","z":"adfd800e.48ad8","group":"e3042201.b26248","name":"Button","order":7,"width":0,"height":0,"format":"<md-button ng-mousedown=\"send({payload: 1})\" ng-mouseup=\"send({payload: 0})\">Bouton</md-button>","storeOutMessages":true,"fwdInMessages":true,"templateScope":"local","x":70,"y":960,"wires":[["5878eb1.f344b94"]]},{"id":"94d3b278.16a9e","type":"inject","z":"adfd800e.48ad8","name":"Init lightState","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":true,"onceDelay":0.1,"x":620,"y":100,"wires":[["8df3c278.80711"]]},{"id":"8df3c278.80711","type":"function","z":"adfd800e.48ad8","name":"Init lightState","func":"flow.set('lightState', 0);\nreturn msg;","outputs":1,"noerr":0,"x":840,"y":100,"wires":[[]]},{"id":"37d89326.dcb004","type":"inject","z":"adfd800e.48ad8","name":"Init status","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":true,"onceDelay":0.1,"x":820,"y":1140,"wires":[["7a636182.0c6548"]]},{"id":"7a636182.0c6548","type":"switch","z":"adfd800e.48ad8","name":"lightState 1/0","property":"lightState","propertyType":"flow","rules":[{"t":"eq","v":"1","vt":"num"},{"t":"eq","v":"0","vt":"num"}],"checkall":"true","repair":false,"outputs":2,"x":840,"y":1080,"wires":[["3d884590.e903ba"],["82392788.93ec98"]]},{"id":"b6a430e9.d8d66","type":"function","z":"adfd800e.48ad8","name":"Push actions","func":"var state = flow.get('lightState');\nflow.set('previousState', state);\n\n\nif (state) {\n   //do something? no...\n}\n\n\nif (state == 0){\n    flow.set('lightState', 1);\n}\n\n\nnode.status({fill:\"blue\",shape:\"dot\",text: (\"lightState: \" + flow.get('lightState') + \", dimDirection: \" + flow.get('dimDirection') )});\n\nreturn msg;","outputs":1,"noerr":0,"x":560,"y":1040,"wires":[["7a636182.0c6548"]]},{"id":"5878eb1.f344b94","type":"switch","z":"adfd800e.48ad8","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"1","vt":"num"},{"t":"eq","v":"0","vt":"num"}],"checkall":"true","repair":false,"outputs":2,"x":210,"y":960,"wires":[["1df56f0.93dac11"],["e3a0c87e.71297"]]},{"id":"d9a60801.4dcb9","type":"inject","z":"adfd800e.48ad8","name":"Init dimState","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":true,"onceDelay":0.1,"x":610,"y":140,"wires":[["f2c13162.43c2b"]]},{"id":"f2c13162.43c2b","type":"function","z":"adfd800e.48ad8","name":"Init dimState","func":"flow.set('dimState', 0);\nreturn msg;","outputs":1,"noerr":0,"x":830,"y":140,"wires":[[]]},{"id":"97fcbd0d.5e1848","type":"inject","z":"adfd800e.48ad8","name":"Init lightValue","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":true,"onceDelay":0.1,"x":620,"y":180,"wires":[["4a512dc1.71b7e4"]]},{"id":"4a512dc1.71b7e4","type":"function","z":"adfd800e.48ad8","name":"Init lightValue","func":"flow.set('lightValue', 0);\nreturn msg;","outputs":1,"noerr":0,"x":840,"y":180,"wires":[[]]},{"id":"75e656cd.23f9a8","type":"delay","z":"adfd800e.48ad8","name":"","pauseType":"delay","timeout":"500","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":530,"y":920,"wires":[["b53bb795.721528","d31c7c69.6e3698"]]},{"id":"2a0d9186.85b5a6","type":"function","z":"adfd800e.48ad8","name":"clear ","func":"msg.reset=1 ;\nreturn msg;","outputs":1,"noerr":0,"x":550,"y":980,"wires":[["75e656cd.23f9a8"]]},{"id":"b53bb795.721528","type":"function","z":"adfd800e.48ad8","name":"long press","func":"\nreturn msg;","outputs":1,"noerr":0,"x":170,"y":640,"wires":[["4ff64c88.f0eafc","822fdc46.91f368"]]},{"id":"1a467f75.20eab1","type":"function","z":"adfd800e.48ad8","name":"long press release","func":"\nreturn msg;","outputs":1,"noerr":0,"x":150,"y":680,"wires":[["b1e11036.2e549"]]},{"id":"c37541e8.e3dee8","type":"function","z":"adfd800e.48ad8","name":"release","func":"node.status({fill:\"blue\",shape:\"dot\",text: (\"lightState: \" + flow.get('lightState') + \", dimState: \" + flow.get('dimState') + \", isLongClick: \" + flow.get('isLongClick'))});\n\n\nvar state = flow.get('lightState');\nvar dim = flow.get('dimState');\nvar dir = flow.get('dimDirection');\nvar lgClick = flow.get('isLongClick');\nvar previous = flow.get('previousState');\n\nif (dir) flow.set('dimDirection', 0);\nelse flow.set('dimDirection', 1);\n\nif(dim){\n    flow.set('lightState', 1);\n    flow.set('dimState', 0);\n    msg.ls = 1;\n}else {\n    if(!lgClick){\n        if (previous){\n            flow.set('lightState', 0);\n            msg.ls = 2;\n        }else {\n            flow.set('lightState', 1);\n            msg.ls= 3;\n        }\n        \n    }\n}\n   \nreturn msg;","outputs":1,"noerr":0,"x":540,"y":1100,"wires":[["7a636182.0c6548"]]},{"id":"cea2faa0.5ae668","type":"delay","z":"adfd800e.48ad8","name":"","pauseType":"delay","timeout":"5","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":130,"y":740,"wires":[["1a467f75.20eab1"]]},{"id":"ac2dbc85.aa7c98","type":"inject","z":"adfd800e.48ad8","name":"Init isLongClick","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":true,"onceDelay":0.1,"x":620,"y":220,"wires":[["5f399854.7dab18"]]},{"id":"5f399854.7dab18","type":"function","z":"adfd800e.48ad8","name":"Init isLongClick","func":"flow.set('isLongClick', 0);\nreturn msg;","outputs":1,"noerr":0,"x":840,"y":220,"wires":[[]]},{"id":"b25ddcb7.39376","type":"function","z":"adfd800e.48ad8","name":"isLongClick = 0","func":"flow.set('isLongClick', 0);\nreturn msg;","outputs":1,"noerr":0,"x":920,"y":1000,"wires":[[]]},{"id":"d31c7c69.6e3698","type":"function","z":"adfd800e.48ad8","name":"isLongClick = 1","func":"flow.set('isLongClick', 1);\nreturn msg;","outputs":1,"noerr":0,"x":760,"y":920,"wires":[[]]},{"id":"f5ebdc11.9ae5a","type":"delay","z":"adfd800e.48ad8","name":"","pauseType":"delay","timeout":"5","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":730,"y":1000,"wires":[["b25ddcb7.39376"]]},{"id":"f4e18e98.40552","type":"mqtt out","z":"adfd800e.48ad8","name":"Switch light ON/OFF","topic":"/lumieres/ESCALIER-LUM1/relay/0/set","qos":"","retain":"","broker":"cd783833.0683e","x":1380,"y":1080,"wires":[]},{"id":"ec9dcb49.bdec18","type":"function","z":"adfd800e.48ad8","name":"ON","func":"msg.payload = 1 ;\nreturn msg;","outputs":1,"noerr":0,"x":1170,"y":1060,"wires":[["f4e18e98.40552"]]},{"id":"c567fdd3.1d763","type":"function","z":"adfd800e.48ad8","name":"OFF","func":"msg.payload = 0 ;\nreturn msg;","outputs":1,"noerr":0,"x":1170,"y":1100,"wires":[["f4e18e98.40552"]]},{"id":"dba4da93.15232","type":"mqtt in","z":"adfd800e.48ad8","name":"Power status","topic":"/lumieres/ESCALIER-LUM1/channel/3","qos":"0","broker":"cd783833.0683e","x":90,"y":540,"wires":[["b1ad5d1a.14ec68"]]},{"id":"3b5b4596.8b59f2","type":"mqtt out","z":"adfd800e.48ad8","name":"Set power to light","topic":"/lumieres/ESCALIER-LUM1/channel/3/set","qos":"","retain":"","broker":"cd783833.0683e","x":790,"y":580,"wires":[]},{"id":"59c368c9.8837b8","type":"ui_slider","z":"adfd800e.48ad8","name":"Dimmer slider","label":"","group":"e3042201.b26248","order":51,"width":"4","height":"1","passthru":true,"outs":"all","topic":"","min":"1","max":"255","step":"1","x":560,"y":540,"wires":[["8c70e401.a453c8","3b5b4596.8b59f2"]]},{"id":"219a3151.798046","type":"link in","z":"adfd800e.48ad8","name":"PUSH BUTTON ON","links":["b29b5126.f6967"],"x":175,"y":920,"wires":[["1df56f0.93dac11"]]},{"id":"4509e036.75a69","type":"link in","z":"adfd800e.48ad8","name":"PUSH BUTTON OFF","links":["20c36c0f.738f64"],"x":175,"y":1000,"wires":[["e3a0c87e.71297"]]},{"id":"1df56f0.93dac11","type":"function","z":"adfd800e.48ad8","name":"PUSH","func":"\nreturn msg;","outputs":1,"noerr":0,"x":330,"y":920,"wires":[["75e656cd.23f9a8","b6a430e9.d8d66"]]},{"id":"e3a0c87e.71297","type":"function","z":"adfd800e.48ad8","name":"RELEASE","func":"\nreturn msg;","outputs":1,"noerr":0,"x":350,"y":1000,"wires":[["2a0d9186.85b5a6","f5ebdc11.9ae5a","c37541e8.e3dee8","cea2faa0.5ae668"]]},{"id":"b1ad5d1a.14ec68","type":"delay","z":"adfd800e.48ad8","name":"","pauseType":"rate","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"5","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":true,"x":300,"y":540,"wires":[["59c368c9.8837b8"]]},{"id":"837553f9.f463a","type":"comment","z":"adfd800e.48ad8","name":"Initialisation of all variables","info":"","x":140,"y":40,"wires":[]},{"id":"bb13e7c5.60974","type":"comment","z":"adfd800e.48ad8","name":"Handling the dimming part","info":"","x":130,"y":420,"wires":[]},{"id":"e37aa437.ed0978","type":"comment","z":"adfd800e.48ad8","name":"And here is the handling of the light ON/OFF switching","info":"","x":230,"y":1080,"wires":[]},{"id":"4bc6dcaf.49ac34","type":"inject","z":"adfd800e.48ad8","name":"Init previousState","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":true,"onceDelay":0.1,"x":630,"y":260,"wires":[["4bdb8684.dee44"]]},{"id":"4bdb8684.dee44","type":"function","z":"adfd800e.48ad8","name":"Init previousState","func":"flow.set('previousState', 0);\nreturn msg;","outputs":1,"noerr":0,"x":850,"y":260,"wires":[[]]},{"id":"e4560f8.a8d3c7","type":"inject","z":"adfd800e.48ad8","name":"Init longPressDelay","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":true,"onceDelay":0.1,"x":640,"y":300,"wires":[["74dece0.fdf333"]]},{"id":"74dece0.fdf333","type":"function","z":"adfd800e.48ad8","name":"Init longPressDelay","func":"// Delay in milliseconds\n\nflow.set('longPressDelay', 400 );\nreturn msg;","outputs":1,"noerr":0,"x":860,"y":300,"wires":[[]]},{"id":"9cd0ad30.c223a","type":"inject","z":"adfd800e.48ad8","name":"Init long press delay node","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":true,"onceDelay":"0.3","x":160,"y":860,"wires":[["f006b957.28c9e"]]},{"id":"f006b957.28c9e","type":"function","z":"adfd800e.48ad8","name":"Init long press delay ","func":"node.status({fill:\"green\",shape:\"dot\",text: (\"Delay: \" + flow.get('longPressDelay'))});\n\nmsg.delay = flow.get('longPressDelay');\n\nreturn msg;","outputs":1,"noerr":0,"x":420,"y":860,"wires":[["75e656cd.23f9a8"]]},{"id":"e3042201.b26248","type":"ui_group","z":"","name":"Test variateur","tab":"5a3a2b45.2019ac","order":1,"disp":true,"width":"6","collapse":false},{"id":"cd783833.0683e","type":"mqtt-broker","z":"","broker":"127.0.0.1","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"5a3a2b45.2019ac","type":"ui_tab","z":"","name":"Boutons","icon":"home","order":1}]

This has been done before - recently.

Multipress of a button

Maybe down to post 7.

FYI Guys
You can now use this plugin without tosmota flashing

Hi,

I bumped into a same kinda problem.
Just got the solution to my version, maybe it can help you...

(this works with hue and mqtt)

I got a fysical button and a sensor to register movement,
on extra I have a switch and a slider to control via dashboard.
Now when I press the button for short then I toggle the light on/off.
When I hold it for longer the dimming starts, initial value 50, to 10 to 100 to 10 etc.... in steps of 10
when I release the dimming stops on the brightness I want.

Other conditions I wanted are:

  • no toggle via movement if switch is active
  • only dim function if light is active

its mainly in dutch, reply if you want a custom one in english

[{"id":"a65b9209.c4078","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"1dd9a58c.f325ea","type":"ui_switch","z":"a65b9209.c4078","name":"","label":"Schilderij","tooltip":"","group":"e34e0a2.727b0f8","order":1,"width":3,"height":1,"passthru":false,"decouple":"true","topic":"","style":"","onvalue":"on","onvalueType":"str","onicon":"","oncolor":"","offvalue":"false","offvalueType":"bool","officon":"","offcolor":"","x":1360,"y":240,"wires":[["2f5f7380.2cbf6c","629a9dc6.f71d94"]]},{"id":"852f007d.d5a57","type":"trigger","z":"a65b9209.c4078","op1":"","op2":"Beweging living laag","op1type":"nul","op2type":"str","duration":"45","extend":true,"units":"s","reset":"Beweging keuken hoog","bytopic":"all","name":"Delay 45s","x":620,"y":180,"wires":[["ed57796d.c06d58"]]},{"id":"deaeb68c.d20f88","type":"switch","z":"a65b9209.c4078","name":"Catch msg","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"Beweging living hoog","vt":"str"},{"t":"eq","v":"Beweging living laag","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":410,"y":160,"wires":[["852f007d.d5a57","ed57796d.c06d58"],["852f007d.d5a57"]]},{"id":"ed57796d.c06d58","type":"change","z":"a65b9209.c4078","name":"Convert msg","rules":[{"t":"change","p":"payload","pt":"msg","from":"Beweging living hoog","fromt":"str","to":"30","tot":"num"},{"t":"change","p":"payload","pt":"msg","from":"Beweging living laag","fromt":"str","to":"false","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":810,"y":160,"wires":[["8d3f35bf.e35658"]]},{"id":"c4760def.5b418","type":"gate","z":"a65b9209.c4078","name":"Knop ok?","controlTopic":"knop ok","defaultState":"open","openCmd":"false","closeCmd":"on","toggleCmd":"toggle","defaultCmd":"default","persist":false,"x":1560,"y":100,"wires":[["629a9dc6.f71d94"]]},{"id":"54ed90fc.44f42","type":"get-shared-state","z":"a65b9209.c4078","state":"c015dd83.b91a7","name":"Schemering","triggerOnInit":true,"x":410,"y":100,"wires":[["dd046efb.d3e5f"]]},{"id":"3b661f58.c02e1","type":"function","z":"a65b9209.c4078","name":"Add 10","func":"msg.payload = parseFloat(msg.payload + 10);\nreturn msg;","outputs":1,"noerr":0,"x":1660,"y":460,"wires":[["242ad898.1e9708"]]},{"id":"242ad898.1e9708","type":"delay","z":"a65b9209.c4078","name":"","pauseType":"delay","timeout":"1200","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":1820,"y":460,"wires":[["68d03763.663bf8"]]},{"id":"2eed2264.14e6ee","type":"switch","z":"a65b9209.c4078","name":"Go to 0","property":"payload","propertyType":"msg","rules":[{"t":"btwn","v":"101","vt":"num","v2":"20","v2t":"num"},{"t":"eq","v":"10","vt":"num"}],"checkall":"true","repair":false,"outputs":2,"x":1500,"y":360,"wires":[["143bf63e.e3d74a"],["fca84324.1c98d"]]},{"id":"143bf63e.e3d74a","type":"function","z":"a65b9209.c4078","name":"Sub 10","func":"msg.payload = parseFloat(msg.payload - 10);\nreturn msg;","outputs":1,"noerr":0,"x":1660,"y":320,"wires":[["dc1186f.21e1978"]]},{"id":"dc1186f.21e1978","type":"delay","z":"a65b9209.c4078","name":"","pauseType":"delay","timeout":"1200","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":1820,"y":320,"wires":[["7c85307a.2b96b"]]},{"id":"c86b22b.ec1a4e","type":"function","z":"a65b9209.c4078","name":"back","func":"return [\n    { payload: msg.payload.on },\n    { payload: msg.payload.hex },\n    { payload: msg.payload.bri }\n];","outputs":3,"noerr":0,"x":610,"y":240,"wires":[["68791c4a.2e13b4"],[],[]]},{"id":"396a4471.2272dc","type":"node-hue-out","z":"a65b9209.c4078","server":"847fe766.259388","lightID":"group16","name":"Feed","x":390,"y":240,"wires":[["c86b22b.ec1a4e"]]},{"id":"7bf2329c.c1ca3c","type":"gate","z":"a65b9209.c4078","name":"","controlTopic":"toggle ok","defaultState":"closed","openCmd":"false","closeCmd":"true","toggleCmd":"toggle","defaultCmd":"default","persist":false,"x":1350,"y":180,"wires":[["2f5f7380.2cbf6c","629a9dc6.f71d94"]]},{"id":"37404eec.78f252","type":"ui_text_input","z":"a65b9209.c4078","name":"","label":"To topic","tooltip":"","group":"b5f83b43.7d2248","order":1,"width":0,"height":0,"passthru":true,"mode":"text","delay":300,"topic":"toggle ok","x":1000,"y":240,"wires":[["7bf2329c.c1ca3c","6ddc8b4.c28d574","4c47e390.9f008c","4cfdea00.410438","dc0cddb9.91a22","8998c0db.340f7"]]},{"id":"68791c4a.2e13b4","type":"change","z":"a65b9209.c4078","name":"change","rules":[{"t":"change","p":"payload","pt":"msg","from":"true","fromt":"str","to":"close","tot":"str"},{"t":"change","p":"payload","pt":"msg","from":"false","fromt":"str","to":"open","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":800,"y":240,"wires":[["37404eec.78f252"]]},{"id":"6ddc8b4.c28d574","type":"gate","z":"a65b9209.c4078","name":"","controlTopic":"toggle ok","defaultState":"closed","openCmd":"true","closeCmd":"false","toggleCmd":"toggle","defaultCmd":"default","persist":false,"x":1350,"y":120,"wires":[["2f5f7380.2cbf6c","629a9dc6.f71d94"]]},{"id":"fca84324.1c98d","type":"delay","z":"a65b9209.c4078","name":"","pauseType":"delay","timeout":"1200","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":1680,"y":360,"wires":[["ff7d52ef.bb485"]]},{"id":"4c7d0f6c.c576e","type":"delay","z":"a65b9209.c4078","name":"","pauseType":"delay","timeout":"1200","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":1680,"y":420,"wires":[["2eed2264.14e6ee"]]},{"id":"d4afa0c9.20ba5","type":"ui_slider","z":"a65b9209.c4078","name":"schilderij","label":"","tooltip":"","group":"e34e0a2.727b0f8","order":3,"width":3,"height":1,"passthru":true,"outs":"end","topic":"","min":"10","max":"100","step":"10","x":1360,"y":300,"wires":[["629a9dc6.f71d94"]]},{"id":"fc6f24c9.7f1f38","type":"change","z":"a65b9209.c4078","name":"change","rules":[{"t":"set","p":"payload","pt":"msg","to":"false","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1180,"y":120,"wires":[["6ddc8b4.c28d574"]]},{"id":"74cf50b8.aab27","type":"change","z":"a65b9209.c4078","name":"change","rules":[{"t":"set","p":"payload","pt":"msg","to":"on","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1180,"y":180,"wires":[["7bf2329c.c1ca3c"]]},{"id":"ff7d52ef.bb485","type":"switch","z":"a65b9209.c4078","name":"Go to 100","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"100","vt":"num"},{"t":"btwn","v":"9","vt":"num","v2":"90","v2t":"num"}],"checkall":"true","repair":false,"outputs":2,"x":1500,"y":420,"wires":[["4c7d0f6c.c576e"],["3b661f58.c02e1"]]},{"id":"4c47e390.9f008c","type":"gate","z":"a65b9209.c4078","name":"","controlTopic":"toggle ok","defaultState":"closed","openCmd":"true","closeCmd":"false","toggleCmd":"toggle","defaultCmd":"default","persist":false,"x":1350,"y":360,"wires":[["2eed2264.14e6ee"]]},{"id":"4cfdea00.410438","type":"gate","z":"a65b9209.c4078","name":"","controlTopic":"toggle ok","defaultState":"closed","openCmd":"true","closeCmd":"false","toggleCmd":"toggle","defaultCmd":"default","persist":false,"x":1350,"y":420,"wires":[["ff7d52ef.bb485"]]},{"id":"dc0cddb9.91a22","type":"change","z":"a65b9209.c4078","name":"change","rules":[{"t":"change","p":"payload","pt":"msg","from":"true","fromt":"bool","to":"on","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1180,"y":240,"wires":[["1dd9a58c.f325ea"]]},{"id":"2f5f7380.2cbf6c","type":"ui_text_input","z":"a65b9209.c4078","name":"","label":"To topic","tooltip":"","group":"b5f83b43.7d2248","order":1,"width":0,"height":0,"passthru":true,"mode":"text","delay":300,"topic":"knop ok","x":1640,"y":180,"wires":[["c4760def.5b418"]]},{"id":"8f8338fa.125bf8","type":"comment","z":"a65b9209.c4078","name":"Bewegingsmelder","info":"","x":150,"y":100,"wires":[]},{"id":"dd046efb.d3e5f","type":"ui_text_input","z":"a65b9209.c4078","name":"","label":"To topic","tooltip":"","group":"b5f83b43.7d2248","order":1,"width":0,"height":0,"passthru":true,"mode":"text","delay":300,"topic":"schemering","x":800,"y":100,"wires":[["8d3f35bf.e35658"]]},{"id":"8d3f35bf.e35658","type":"gate","z":"a65b9209.c4078","name":"schemering","controlTopic":"schemering","defaultState":"open","openCmd":"false","closeCmd":"on","toggleCmd":"toggle","defaultCmd":"default","persist":false,"x":1010,"y":100,"wires":[["c4760def.5b418"]]},{"id":"c8934ba.58064b8","type":"comment","z":"a65b9209.c4078","name":"Dashboard","info":"","x":120,"y":220,"wires":[]},{"id":"629a9dc6.f71d94","type":"node-hue-in","z":"a65b9209.c4078","server":"847fe766.259388","lightID":"group16","name":"Lampgroep schilderij","x":1680,"y":240,"wires":[]},{"id":"a2464d99.09619","type":"ui_switch","z":"a65b9209.c4078","name":"","label":"switch","tooltip":"","group":"ca5aecaa.4f9ee","order":2,"width":0,"height":0,"passthru":true,"decouple":"false","topic":"","style":"","onvalue":"Knop3A hoog","onvalueType":"str","onicon":"","oncolor":"","offvalue":"Knop3A laag","offvalueType":"str","officon":"","offcolor":"","x":250,"y":420,"wires":[["681ac9e7.1c7598"]]},{"id":"e563f04b.991cb","type":"change","z":"a65b9209.c4078","name":"true to 50","rules":[{"t":"change","p":"payload","pt":"msg","from":"true","fromt":"str","to":"60","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":800,"y":420,"wires":[["7c85307a.2b96b"]]},{"id":"a532edc4.89b48","type":"ui_text_input","z":"a65b9209.c4078","name":"","label":"To topic","tooltip":"","group":"b5f83b43.7d2248","order":1,"width":0,"height":0,"passthru":true,"mode":"text","delay":300,"topic":"dim ok","x":800,"y":360,"wires":[["7c85307a.2b96b","68d03763.663bf8","14b5bc46.f22d84"]]},{"id":"7c85307a.2b96b","type":"gate","z":"a65b9209.c4078","name":"","controlTopic":"dim ok","defaultState":"closed","openCmd":"true","closeCmd":"false","toggleCmd":"","defaultCmd":"","persist":false,"x":990,"y":360,"wires":[["4c47e390.9f008c","8998c0db.340f7"]]},{"id":"68d03763.663bf8","type":"gate","z":"a65b9209.c4078","name":"","controlTopic":"dim ok","defaultState":"closed","openCmd":"true","closeCmd":"false","toggleCmd":"","defaultCmd":"","persist":false,"x":990,"y":420,"wires":[["4cfdea00.410438","8998c0db.340f7"]]},{"id":"7b6fcade.fa2014","type":"trigger","z":"a65b9209.c4078","op1":"","op2":"true","op1type":"nul","op2type":"str","duration":"1000","extend":false,"units":"ms","reset":"false","bytopic":"all","name":"","x":620,"y":420,"wires":[["e563f04b.991cb"]]},{"id":"c4f4d3ae.d15ad","type":"get-shared-state","z":"a65b9209.c4078","state":"319388bf.3b0b48","name":"StatA3","triggerOnInit":true,"x":110,"y":340,"wires":[["5fac1fc1.0f067","deaeb68c.d20f88"]]},{"id":"5fac1fc1.0f067","type":"switch","z":"a65b9209.c4078","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"Knop3A hoog","vt":"str"},{"t":"eq","v":"Knop3A laag","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":250,"y":360,"wires":[["681ac9e7.1c7598"],["681ac9e7.1c7598"]]},{"id":"681ac9e7.1c7598","type":"change","z":"a65b9209.c4078","name":"","rules":[{"t":"change","p":"payload","pt":"msg","from":"Knop3A hoog","fromt":"str","to":"true","tot":"str"},{"t":"change","p":"payload","pt":"msg","from":"Knop3A laag","fromt":"str","to":"false","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":420,"y":360,"wires":[["7b6fcade.fa2014","394361c9.62513e","faa60014.c21b8"]]},{"id":"14b5bc46.f22d84","type":"gate","z":"a65b9209.c4078","name":"","controlTopic":"dim ok","defaultState":"open","openCmd":"false","closeCmd":"true","toggleCmd":"toggle","defaultCmd":"default","persist":false,"x":990,"y":300,"wires":[["fc6f24c9.7f1f38","74cf50b8.aab27"]]},{"id":"c9bb796a.5ea9b8","type":"delay","z":"a65b9209.c4078","name":"","pauseType":"delay","timeout":"950","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":810,"y":300,"wires":[["14b5bc46.f22d84"]]},{"id":"394361c9.62513e","type":"switch","z":"a65b9209.c4078","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"true","vt":"str"},{"t":"eq","v":"false","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":610,"y":300,"wires":[["c9bb796a.5ea9b8"],["a532edc4.89b48"]]},{"id":"faa60014.c21b8","type":"trigger","z":"a65b9209.c4078","op1":"","op2":"true","op1type":"nul","op2type":"str","duration":"900","extend":false,"units":"ms","reset":"false","bytopic":"all","name":"","x":620,"y":360,"wires":[["a532edc4.89b48"]]},{"id":"8182ee85.4e5a3","type":"comment","z":"a65b9209.c4078","name":"Dimmer","info":"","x":110,"y":420,"wires":[]},{"id":"6544883d.5b71a8","type":"comment","z":"a65b9209.c4078","name":"Drukknop","info":"","x":120,"y":300,"wires":[]},{"id":"8998c0db.340f7","type":"gate","z":"a65b9209.c4078","name":"","controlTopic":"toggle ok","defaultState":"closed","openCmd":"true","closeCmd":"false","toggleCmd":"toggle","defaultCmd":"default","persist":false,"x":1170,"y":380,"wires":[["d4afa0c9.20ba5"]]},{"id":"e34e0a2.727b0f8","type":"ui_group","z":"","name":"Living","tab":"d7faa1c9.200ce","order":2,"disp":true,"width":"7","collapse":false},{"id":"c015dd83.b91a7","type":"shared-state","z":"","name":"Schemering","historyCount":"1"},{"id":"847fe766.259388","type":"node-hue-bridge","z":"","name":"Hue Bridge","address":"192.168.1.126","key":"HRWKi0yzh0Bz5Ck1jRi4svjyYdhY7UGRKrNktQ4U","interval":"1000"},{"id":"b5f83b43.7d2248","type":"ui_group","z":"","name":"Rommel","tab":"c98b4360.d3603","order":3,"disp":true,"width":"6","collapse":false},{"id":"ca5aecaa.4f9ee","type":"ui_group","z":"","name":"Alarm","tab":"d7faa1c9.200ce","order":1,"disp":true,"width":"7","collapse":true},{"id":"319388bf.3b0b48","type":"shared-state","z":"","name":"StatA3","historyCount":"1"},{"id":"d7faa1c9.200ce","type":"ui_tab","z":"","name":"Home","icon":"dashboard","order":1,"disabled":false,"hidden":false},{"id":"c98b4360.d3603","type":"ui_tab","z":"","name":"For program use","icon":"dashboard","order":5,"disabled":false,"hidden":true}]