Who wants to help me with Node-RED flow based on MQTT log?

I received the EcoDim ED-10014, a wall switch with 8 buttons (4 on and 4 off buttons).
After installing the Node-RED add-on I started to play with it.
I loaded some ‘examples’ and could do some automations.
Unfortunately my knowledge is to limited to achieve an automations with the wall switch as I want it;

Below is the MQTT log:

MQTT publish: topic 'zigbee2mqtt/Muurknop_Living', payload '{"action":"on_1","action_group":54529,"battery":100,"linkquality":102}'
info MQTT publish: topic 'zigbee2mqtt/Muurknop_Living', payload '{"action":"","battery":100,"linkquality":102}'
info MQTT publish: topic 'zigbee2mqtt/Muurknop_Living/action', payload 'on_1'
info MQTT publish: topic 'zigbee2mqtt/Muurknop_Living', payload '{"action":"off_1","action_group":54529,"battery":100,"linkquality":93}'
info MQTT publish: topic 'zigbee2mqtt/Muurknop_Living', payload '{"action":"","battery":100,"linkquality":93}'
info MQTT publish: topic 'zigbee2mqtt/Muurknop_Living/action', payload 'off_1'
info MQTT publish: topic 'zigbee2mqtt/Muurknop_Living', payload '{"action":"brightness_move_up_1","action_group":54529,"action_rate":50,"battery":100,"linkquality":108}'
info MQTT publish: topic 'zigbee2mqtt/Muurknop_Living', payload '{"action":"","battery":100,"linkquality":108}'
info MQTT publish: topic 'zigbee2mqtt/Muurknop_Living/action', payload 'brightness_move_up_1'
info MQTT publish: topic 'zigbee2mqtt/Muurknop_Living', payload '{"action":"brightness_stop_1","action_group":54529,"battery":100,"linkquality":102}'
info MQTT publish: topic 'zigbee2mqtt/Muurknop_Living', payload '{"action":"","battery":100,"linkquality":102}'
info MQTT publish: topic 'zigbee2mqtt/Muurknop_Living/action', payload 'brightness_stop_1'
info MQTT publish: topic 'zigbee2mqtt/Muurknop_Living', payload '{"action":"brightness_move_down_1","action_group":54529,"action_rate":50,"battery":100,"linkquality":105}'
info MQTT publish: topic 'zigbee2mqtt/Muurknop_Living', payload '{"action":"","battery":100,"linkquality":105}'
info MQTT publish: topic 'homeassistant/device_automation/0xbc33acfffe5f4bc1/action_brightness_move_down_1/config', payload '{"automation_type":"trigger","device":{"identifiers":["zigbee2mqtt_0xbc33acfffe5f4bc1"],"manufacturer":"EcoDim","model":"Zigbee 8 button wall switch - white (ED-10014)","name":"Muurknop_Living","sw_version":"Zigbee2MQTT 1.17.1"},"payload":"brightness_move_down_1","subtype":"brightness_move_down_1","topic":"zigbee2mqtt/Muurknop_Living/action","type":"action"}'
info MQTT publish: topic 'zigbee2mqtt/Muurknop_Living/action', payload 'brightness_move_down_1'
info MQTT publish: topic 'zigbee2mqtt/Muurknop_Living', payload '{"action":"brightness_stop_1","action_group":54529,"battery":100,"linkquality":108}'
info MQTT publish: topic 'zigbee2mqtt/Muurknop_Living', payload '{"action":"","battery":100,"linkquality":108}'
info MQTT publish: topic 'zigbee2mqtt/Muurknop_Living/action', payload 'brightness_stop_1'

Single press button 1 (= ON) = payload ‘on_1’
Single press button 2 (= OFF) = payload ‘off_1’
Long press button 1 (= Dim up) = payload ‘brightness_move_up_1’
When releasing button 1 (= Stop Dim up) = payload ‘brightness_stop_1’
Long press button 2 (= Dim down) = payload ‘brightness_move_down_1’
When releasing button 2 (= Stop Dim up) = payload ‘brightness_stop_1’

I like to use the above actions to control a bulb1.
The logical actions should be:

  • Single press ON: bulb on
  • Long press ON: bulb intensity increase by steps of 10% till 100%
  • If ON long press released: hold intensity
  • Single press OFF: bulb off
  • Long press OFF: bulb decrease intensity by steps of 10% till 10%
  • If OFF long press released: hold intensity

Of course, once I have the example for buttons 1/2 I can copy/paste it for buttons 3/4, 5/6 and 7/8.

Would you be able to make a Node-RED flow for me?
Many thanks in advance

i think you probanly only need a mqtt node with a switch node. happy automating

Thanks for your answer @Flipso
The switch node can indeed be used to switch on of off the bulb but for the dimmer function (increase / decrease brigtness), I believe I need some ‘programming’

Why use node red at all?

Work in progress…
On and off are working.
Found on this forum an example based on a Trust remote control with on/off/dim-up/dim-down buttons. Used the same base for my flow:

[{"id":"aaeb84d7.0184e","type":"tab","label":"EcoDim WallSwitch","disabled":false,"info":""},{"id":"1ac57c78.e1f95c","type":"mqtt in","z":"aaeb84d7.0184e","name":"","topic":"zigbee2mqtt/Muurknop_Living","qos":"2","datatype":"auto","broker":"aa4be58a.022348","x":140,"y":120,"wires":[["a78131b.2a0c15"]]},{"id":"a78131b.2a0c15","type":"json","z":"aaeb84d7.0184e","name":"","property":"payload","action":"","pretty":false,"x":350,"y":120,"wires":[["e317f91d.4b0e08"]]},{"id":"e317f91d.4b0e08","type":"switch","z":"aaeb84d7.0184e","name":"1 On, off, up, down","property":"payload.action","propertyType":"msg","rules":[{"t":"eq","v":"on_1","vt":"str"},{"t":"eq","v":"off_1","vt":"str"},{"t":"eq","v":"brightness_move_up_1","vt":"str"},{"t":"eq","v":"brightness_move_down_1","vt":"str"}],"checkall":"true","repair":true,"outputs":4,"x":550,"y":120,"wires":[["67d2aabc.bfb5c4"],["755eb9df.e9b27"],["613d42ed.470f7c"],["149d69d3.ae0a2e"]]},{"id":"67d2aabc.bfb5c4","type":"api-call-service","z":"aaeb84d7.0184e","name":"Zithoek lampen aan","server":"34d61653.1cc8c2","version":1,"debugenabled":false,"service_domain":"light","service":"turn_on","entityId":"light.alle_lampen_zithoek","data":"","dataType":"json","mergecontext":"","output_location":"payload","output_location_type":"msg","mustacheAltTags":false,"x":830,"y":20,"wires":[[]]},{"id":"755eb9df.e9b27","type":"api-call-service","z":"aaeb84d7.0184e","name":"Zithoek lampen uit","server":"34d61653.1cc8c2","version":1,"debugenabled":false,"service_domain":"light","service":"turn_off","entityId":"light.alle_lampen_zithoek","data":"","dataType":"json","mergecontext":"","output_location":"payload","output_location_type":"msg","mustacheAltTags":false,"x":830,"y":80,"wires":[[]]},{"id":"613d42ed.470f7c","type":"api-current-state","z":"aaeb84d7.0184e","name":"","server":"89080ee6.7112f8","version":1,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"light.alle_lampen_zithoek","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":900,"y":140,"wires":[["2822be5a.d700fa"]]},{"id":"2822be5a.d700fa","type":"function","z":"aaeb84d7.0184e","name":"Set brightness in payload +32","func":"var brightness = msg.data.attributes.brightness;\n\nif (brightness < 32) {\n brightness = 32;\n} else if (brightness >= 32 && brightness < 64) {\n brightness = 64;\n} else if (brightness >= 64 && brightness < 96) {\n brightness = 96;\n} else if (brightness >= 96 && brightness < 128) {\n brightness = 128;\n} else if (brightness >= 128 && brightness < 160) {\n brightness = 160;\n} else if (brightness >= 160 && brightness < 192) {\n brightness = 192;\n} else if (brightness >= 192 && brightness < 224) {\n brightness = 224;\n} else if (brightness >= 224) {\n brightness = 255;\n} \n\nmsg.payload = {\n domain: 'light',\n service: 'turn_on',\n data: { entity_id: 'light.alle_lampen_zithoek_lamp', brightness: brightness}\n};\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1210,"y":140,"wires":[["67c18b74.dc3c84"]]},{"id":"67c18b74.dc3c84","type":"api-call-service","z":"aaeb84d7.0184e","name":"Set Alle_lampen_zithoek Brightness","server":"89080ee6.7112f8","version":1,"debugenabled":false,"service_domain":"light","service":"turn_on","entityId":"light.alle_lampen_zithoek","data":"","dataType":"json","mergecontext":"","output_location":"payload","output_location_type":"msg","mustacheAltTags":false,"x":1540,"y":160,"wires":[[]]},{"id":"149d69d3.ae0a2e","type":"api-current-state","z":"aaeb84d7.0184e","name":"","server":"89080ee6.7112f8","version":1,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"light.alle_lampen_zithoek","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":900,"y":200,"wires":[["5e4da185.f7751"]]},{"id":"5e4da185.f7751","type":"function","z":"aaeb84d7.0184e","name":"Set brightness in payload -32","func":"var brightness = msg.data.attributes.brightness;\n\nif (brightness > 224) {\n brightness = 224;\n} else if (brightness > 192 && brightness < 225) {\n brightness = 192;\n} else if (brightness > 160 && brightness < 193) {\n brightness = 160;\n} else if (brightness > 128 && brightness < 161) {\n brightness = 128;\n} else if (brightness > 96 && brightness < 129) {\n brightness = 96;\n} else if (brightness > 64 && brightness < 97) {\n brightness = 64;\n} else if (brightness > 32 && brightness < 65) {\n brightness = 32;\n} else if (brightness < 32) {\n brightness = 0;\n}\n\nmsg.payload = {\n domain: 'light',\n service: 'turn_on',\n data: { entity_id: 'light.globe_lamp', brightness: brightness}\n};\nreturn msg;\n","outputs":1,"noerr":0,"x":1210,"y":200,"wires":[["67c18b74.dc3c84"]]},{"id":"aa4be58a.022348","type":"mqtt-broker","name":"Mosquitto","broker":"localhost","port":"1883","tls":"","clientid":"NodeRed","usetls":false,"compatmode":false,"keepalive":"300","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"/unxpected_disconnect","willQos":"0","willPayload":""},{"id":"34d61653.1cc8c2","type":"server","name":"Home Assistant instance","legacy":false,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true},{"id":"89080ee6.7112f8","type":"server","name":"Home Assistant instance","legacy":false,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true}]

On and Off works. Increase / Decrease doesn’t work. The edit switch node with the 4 outputs is working. Outputs 3 and 4 become active but nothing happens…

So in my case im using an xiaomi button for the flow, but the idea should be the same - if i longpress nodered starts a loop which finishes if i release the long press button. the loop then triggers a “brightness_step_pct”:10. so here you go, perhaps this works for u as well. you do have to change the switch node and the corresponding click types and messages

[{“id”:“11a523a1.f17484”,“type”:“looptimer”,“z”:“a600caa7.9f4ac8”,“duration”:“1”,“units”:“Second”,“maxloops”:“10”,“maxtimeout”:“1”,“maxtimeoutunits”:“Minute”,“name”:“”,“x”:1280,“y”:280,“wires”:[[“e0000946.7f7348”],]},{“id”:“e290b258.509c5”,“type”:“change”,“z”:“a600caa7.9f4ac8”,“name”:“”,“rules”:[{“t”:“change”,“p”:“payload”,“pt”:“msg”,“from”:“long”,“fromt”:“str”,“to”:“on”,“tot”:“str”}],“action”:“”,“property”:“”,“from”:“”,“to”:“”,“reg”:false,“x”:1060,“y”:340,“wires”:[[“bf676f98.207b5”]]},{“id”:“bf676f98.207b5”,“type”:“looptimer”,“z”:“a600caa7.9f4ac8”,“duration”:“1”,“units”:“Second”,“maxloops”:“10”,“maxtimeout”:“1”,“maxtimeoutunits”:“Minute”,“name”:“”,“x”:1280,“y”:360,“wires”:[[“c2212bb2.9c107”],]},{“id”:“fb75e72.7d5b498”,“type”:“ha-get-entities”,“z”:“a600caa7.9f4ac8”,“server”:“e1a09eea.dc823”,“name”:“”,“rules”:[{“property”:“entity_id”,“logic”:“includes”,“value”:“light.osram_3”,“valueType”:“str”},{“property”:“attributes.brightness”,“logic”:“gt”,“value”:“100”,“valueType”:“num”}],“output_type”:“count”,“output_empty_results”:true,“output_location_type”:“msg”,“output_location”:“payload1”,“output_results_count”:1,“x”:550,“y”:320,“wires”:[[“ab18907b.d43c48”]]},{“id”:“ab18907b.d43c48”,“type”:“switch”,“z”:“a600caa7.9f4ac8”,“name”:“”,“property”:“payload1”,“propertyType”:“msg”,“rules”:[{“t”:“eq”,“v”:“0”,“vt”:“str”},{“t”:“gt”,“v”:“0”,“vt”:“str”}],“checkall”:“true”,“repair”:true,“outputs”:2,“x”:670,“y”:320,“wires”:[[“46a545d0.f9b95c”],[“c3f772a5.a42998”]]},{“id”:“c3f772a5.a42998”,“type”:“switch”,“z”:“a600caa7.9f4ac8”,“name”:“Button Click Type”,“property”:“payload”,“propertyType”:“msg”,“rules”:[{“t”:“eq”,“v”:“long”,“vt”:“str”},{“t”:“eq”,“v”:“long_release”,“vt”:“str”}],“checkall”:“true”,“repair”:false,“outputs”:2,“x”:830,“y”:360,“wires”:[[“e290b258.509c5”],]},{“id”:“db4d38b5.0d256”,“type”:“change”,“z”:“a600caa7.9f4ac8”,“name”:“”,“rules”:[{“t”:“set”,“p”:“payload”,“pt”:“msg”,“to”:“stop”,“tot”:“str”}],“action”:“”,“property”:“”,“from”:“”,“to”:“”,“reg”:false,“x”:1050,“y”:300,“wires”:[[“11a523a1.f17484”]]},{“id”:“c1c580cc.4dcb3”,“type”:“change”,“z”:“a600caa7.9f4ac8”,“name”:“”,“rules”:[{“t”:“change”,“p”:“payload”,“pt”:“msg”,“from”:“long”,“fromt”:“str”,“to”:“on”,“tot”:“str”}],“action”:“”,“property”:“”,“from”:“”,“to”:“”,“reg”:false,“x”:1060,“y”:260,“wires”:[[“11a523a1.f17484”]]},{“id”:“46a545d0.f9b95c”,“type”:“switch”,“z”:“a600caa7.9f4ac8”,“name”:“Button Click Type”,“property”:“payload”,“propertyType”:“msg”,“rules”:[{“t”:“eq”,“v”:“long”,“vt”:“str”},{“t”:“eq”,“v”:“long_release”,“vt”:“str”}],“checkall”:“true”,“repair”:false,“outputs”:2,“x”:830,“y”:280,“wires”:[[“c1c580cc.4dcb3”],]},{“id”:“df549605.1f177”,“type”:“change”,“z”:“a600caa7.9f4ac8”,“name”:“”,“rules”:[{“t”:“set”,“p”:“payload”,“pt”:“msg”,“to”:“stop”,“tot”:“str”}],“action”:“”,“property”:“”,“from”:“”,“to”:“”,“reg”:false,“x”:1050,“y”:380,“wires”:[[“bf676f98.207b5”]]},{“id”:“a6b2e899.9ce718”,“type”:“switch”,“z”:“a600caa7.9f4ac8”,“name”:“Button Click Type”,“property”:“payload”,“propertyType”:“msg”,“rules”:[{“t”:“eq”,“v”:“single”,“vt”:“str”},{“t”:“eq”,“v”:“double”,“vt”:“str”},{“t”:“eq”,“v”:“triple”,“vt”:“str”},{“t”:“eq”,“v”:“quadruple”,“vt”:“str”},{“t”:“eq”,“v”:“long”,“vt”:“str”},{“t”:“eq”,“v”:“long_release”,“vt”:“str”}],“checkall”:“true”,“repair”:false,“outputs”:6,“x”:310,“y”:160,“wires”:[[“883a9c27.a80a68”],[“187690de.ea3df7”],,,[“fb75e72.7d5b498”],[“db4d38b5.0d256”,“df549605.1f177”]]},{“id”:“e1a09eea.dc823”,“type”:“server”,“name”:“Home Assistant”,“legacy”:false,“addon”:true,“rejectUnauthorizedCerts”:true,“ha_boolean”:“y|yes|true|on|home|open”,“connectionDelay”:true}]

`

Thanks for your code but when I copy/paste it the result is a syntax error:

SyntaxError: JSON.parse: expected property name or '}' at line 1 column 3 of the JSON data

Can you please use the export function in Node-RED and past it here.

Im sorry, will try to post it later or tomorrow again​:see_no_evil::hugs:

I changed all “ and ” into " and I could import your flow.
Changed your node to my situation but doesn’t work… So, I started step by step;
Schermafbeelding 2021-02-21 om 19.56.07

This is the ‘get entities’:

I made this simple flow to read the actual brightness but the debug node only gives ‘on’ and not the brightness.

this get entites node is there to get the current state of the light, if the light is under 100 it increases the brightness if it is over 100 it starts the loop to dim - they output on because you set output type to count . the switch node and the loops are more of that kind of nodes u need here:

first you need your switch node with your button commands, long press (Long press ON) should then start the loop which uses the call service node for increasing/decresing the light, long_release (Long press OFF) should then stop the loop so it doesnt runs infinitly. because im not really that pro i had to change the payload from “long” and “long_released” to “on” and “off” for the loop to function - for that i used a change node.
Hope that helps somehow =)

Hi, I understood this entity node indeed gets the current state, including the brightness.
This node reads the state (on/off) from then entity but not the brightness.
I know I need first a switch node with long press but this part works.
As this is not the problem and I don’t want to use my remote all the time to test, I made a simulation with Test -> Get Entities -> Debug
When I press the ‘test’, it starts the Get Entities flow and should read the state and the brightness; see details above of my ‘get enities node’. It’s a copy/paste from your example, I only changed the entity_id to my entity_id.
The Debug (msg.payload) on the right is a debug node, just to see the output of the previous node and that’s only the state on/off.

ah perhaps you have to set the debug node to msg.payload5 like your get entita node, youalso can set the debug node to full message to get all the informations available. i channeled the msg in different msg.payload to keep the information - perhaps not the best way of doing this but works 60% of the time everytime