Use debug nodes to see the data going into that function and that coming out. Show us what you see.
I get 7x
object
action: "brightness_step_down"
action_step_size: 30
action_transition_time: 0.09
battery: 100
linkquality: 204
update: object
update_available: false
after that
object
action: "brightness_step_up"
action_step_size: 30
action_transition_time: 0.09
battery: 100
linkquality: 204
update: object
update_available: false
Where is msg.payload.brightness
?
that is probably already the error. i just can't get this to work.
this is my current flow:
[{"id":"0d3aca4a8b577dd0","type":"zigbee2mqtt-in","z":"9f99ca32053f4cbc","name":"","server":"d6cb6dc92f386f45","friendly_name":"Hue Button Bett (8718699693985)","device_id":"0x001788010895e309","state":"0","outputAtStartup":true,"filterChanges":false,"enableMultiple":false,"x":200,"y":1560,"wires":[["06ed3aa389da0c22","30f25d2c38aef683","91b4337005944685","ddb8cbcdd1c69f33","5474ec29f232890c","1b5e5a7a306335c3","30e6402c3125a888","e858a6c014c07806","efa751a6641132c7","33bf8d2187da38e0","bf3364a640d2dfbb"]]},{"id":"b56f8b4396909cb0","type":"debug","z":"9f99ca32053f4cbc","name":"debug2 Bett","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1410,"y":1540,"wires":[]},{"id":"6cdcbc5e9705488b","type":"change","z":"9f99ca32053f4cbc","name":"ON","rules":[{"t":"set","p":"payload","pt":"msg","to":"ON","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":750,"y":1380,"wires":[["735aac978170d275"]]},{"id":"75e98ad6651e9da1","type":"change","z":"9f99ca32053f4cbc","name":"OFF","rules":[{"t":"set","p":"payload","pt":"msg","to":"OFF","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":750,"y":1440,"wires":[["735aac978170d275"]]},{"id":"024af23d5255854f","type":"debug","z":"9f99ca32053f4cbc","name":"battery","active":false,"tosidebar":false,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":760,"y":1820,"wires":[]},{"id":"6e6a51680f088f88","type":"debug","z":"9f99ca32053f4cbc","name":"linkquality","active":false,"tosidebar":false,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":760,"y":1920,"wires":[]},{"id":"6c90ca44fced7831","type":"debug","z":"9f99ca32053f4cbc","name":"update.state","active":false,"tosidebar":false,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":770,"y":2020,"wires":[]},{"id":"bf3364a640d2dfbb","type":"debug","z":"9f99ca32053f4cbc","name":"debug1 Bett","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":190,"y":1640,"wires":[]},{"id":"6ad3467d11634f2b","type":"debug","z":"9f99ca32053f4cbc","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":970,"y":1640,"wires":[]},{"id":"35352aac8174d564","type":"debug","z":"9f99ca32053f4cbc","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":970,"y":1700,"wires":[]},{"id":"b55e7d233b4360d3","type":"debug","z":"9f99ca32053f4cbc","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload.action","targetType":"msg","statusVal":"","statusType":"auto","x":990,"y":1760,"wires":[]},{"id":"06ed3aa389da0c22","type":"switch","z":"9f99ca32053f4cbc","name":"on","property":"payload.action","propertyType":"msg","rules":[{"t":"eq","v":"on","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":510,"y":1380,"wires":[["6cdcbc5e9705488b"]]},{"id":"30f25d2c38aef683","type":"switch","z":"9f99ca32053f4cbc","name":"off","property":"payload.action","propertyType":"msg","rules":[{"t":"eq","v":"off","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":510,"y":1440,"wires":[["75e98ad6651e9da1"]]},{"id":"ddb8cbcdd1c69f33","type":"switch","z":"9f99ca32053f4cbc","name":"brightness_step_up","property":"payload.action","propertyType":"msg","rules":[{"t":"eq","v":"brightness_step_up","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":550,"y":1580,"wires":[["e5bd75249091fc17"]]},{"id":"91b4337005944685","type":"switch","z":"9f99ca32053f4cbc","name":"brightness_step_down","property":"payload.action","propertyType":"msg","rules":[{"t":"eq","v":"brightness_step_down","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":560,"y":1500,"wires":[["5aba77186949b88a"]]},{"id":"1b5e5a7a306335c3","type":"switch","z":"9f99ca32053f4cbc","name":"release","property":"payload.action","propertyType":"msg","rules":[{"t":"eq","v":"release","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":520,"y":1700,"wires":[["1253849ce9b475dc"]]},{"id":"5474ec29f232890c","type":"switch","z":"9f99ca32053f4cbc","name":"press","property":"payload.action","propertyType":"msg","rules":[{"t":"eq","v":"press","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":510,"y":1640,"wires":[["3e0b1a50921aef7e"]]},{"id":"30e6402c3125a888","type":"switch","z":"9f99ca32053f4cbc","name":"hold","property":"payload.action","propertyType":"msg","rules":[{"t":"eq","v":"hold","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":510,"y":1760,"wires":[["1db88b1038ca34de"]]},{"id":"3e0b1a50921aef7e","type":"change","z":"9f99ca32053f4cbc","name":"press","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.action","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":750,"y":1640,"wires":[["6ad3467d11634f2b"]]},{"id":"1253849ce9b475dc","type":"change","z":"9f99ca32053f4cbc","name":"release","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.action","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":760,"y":1700,"wires":[["35352aac8174d564"]]},{"id":"1db88b1038ca34de","type":"change","z":"9f99ca32053f4cbc","name":"hold","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.action","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":750,"y":1760,"wires":[["b55e7d233b4360d3"]]},{"id":"efa751a6641132c7","type":"change","z":"9f99ca32053f4cbc","name":"linkquality","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.linkquality","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":520,"y":1920,"wires":[["6e6a51680f088f88","ce4902b489724d12"]]},{"id":"33bf8d2187da38e0","type":"change","z":"9f99ca32053f4cbc","name":"update.state","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.update.state","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":530,"y":2020,"wires":[["6c90ca44fced7831"]]},{"id":"e858a6c014c07806","type":"change","z":"9f99ca32053f4cbc","name":"battery","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.battery","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":520,"y":1820,"wires":[["024af23d5255854f","092d6897e6e20602"]]},{"id":"5aba77186949b88a","type":"function","z":"9f99ca32053f4cbc","name":"","func":"\n//msg.payload = \"step down \" + msg.payload*-1;\nlet step = msg.payload.action_step_size*-1;\nlet t =msg.payload.action_transition_time;\nmsg.payload = {\"brightness_step_onoff\":-36};\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":760,"y":1500,"wires":[["117ce2f3e69be502"]]},{"id":"e5bd75249091fc17","type":"function","z":"9f99ca32053f4cbc","name":"","func":"//msg.payload = \"step down \" + msg.payload*-1;\nlet step = msg.payload.action_step_size;\nlet t = msg.payload.action_transition_time;\nmsg.payload = {\"brightness_step_onoff\":36};\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":760,"y":1580,"wires":[["117ce2f3e69be502"]]},{"id":"117ce2f3e69be502","type":"function","z":"9f99ca32053f4cbc","name":"Step","func":"return msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":950,"y":1540,"wires":[["b56f8b4396909cb0"]]},{"id":"735aac978170d275","type":"ui_switch","z":"9f99ca32053f4cbc","name":"Bett On / Off","label":"Bett","tooltip":"","group":"b39a769e1a5ab2d0","order":1,"width":0,"height":0,"passthru":true,"decouple":"false","topic":"topic","topicType":"msg","style":"","onvalue":"ON","onvalueType":"str","onicon":"fa-2x fa-toggle-on","oncolor":"red","offvalue":"OFF","offvalueType":"str","officon":"fa-2x fa-toggle-off","offcolor":"green","animate":true,"className":"","x":970,"y":1260,"wires":[["f007b06487862fad"]]},{"id":"f007b06487862fad","type":"function","z":"9f99ca32053f4cbc","name":"ON/OFF","func":"return{payload:{\"state\": msg.payload}};","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1220,"y":1260,"wires":[[]]},{"id":"87b218b902820220","type":"inject","z":"9f99ca32053f4cbc","name":"ON","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"ON","payloadType":"str","x":710,"y":1240,"wires":[["735aac978170d275"]]},{"id":"5aad0f0d8a4c13ce","type":"inject","z":"9f99ca32053f4cbc","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"OFF","payloadType":"str","x":710,"y":1280,"wires":[["735aac978170d275"]]},{"id":"092d6897e6e20602","type":"ui_text","z":"9f99ca32053f4cbc","group":"391030ae3043f7c0","order":3,"width":0,"height":0,"name":"battery","label":"Battery","format":"{{msg.payload}} %","layout":"row-spread","className":"","x":760,"y":1880,"wires":[]},{"id":"ce4902b489724d12","type":"ui_text","z":"9f99ca32053f4cbc","group":"391030ae3043f7c0","order":5,"width":0,"height":0,"name":"linkquality","label":"linkquality","format":"{{msg.payload}} unit","layout":"row-spread","className":"","x":760,"y":1980,"wires":[]},{"id":"d6cb6dc92f386f45","type":"zigbee2mqtt-server","name":"","host":"localhost","mqtt_port":"1883","mqtt_username":"","mqtt_password":"","mqtt_qos":"0","tls":"","usetls":false,"base_topic":"zigbee2mqtt"},{"id":"b39a769e1a5ab2d0","type":"ui_group","name":"Dimmer","tab":"c7e50f4d.33f09","order":4,"disp":true,"width":"6","collapse":false,"className":""},{"id":"391030ae3043f7c0","type":"ui_group","name":"hue button Bett","tab":"b881d91c.f73d98","order":3,"disp":true,"width":"6","collapse":false,"className":""},{"id":"c7e50f4d.33f09","type":"ui_tab","name":"Switches","icon":"mi-toggle_on","order":2,"disabled":false,"hidden":false},{"id":"b881d91c.f73d98","type":"ui_tab","name":"Status","icon":"dashboard","order":4,"disabled":false,"hidden":false}]
can you help me with the flow?
I get only this values from the device:
object
topic: "zigbee2mqtt/Hue Button Eingang"
changed: object
old: object
action: "press"
battery: 100
linkquality: 168
update: object
update_available: false
new: object
action: "brightness_step_down"
action_step_size: 30
action_transition_time: 0.09
battery: 100
linkquality: 168
update: object
update_available: false
payload: object
action: "brightness_step_down"
action_step_size: 30
action_transition_time: 0.09
battery: 100
linkquality: 168
update: object
Hi, I don't understand what you want to achive.
If you want to dimm the light based of the time you press the button you could use "press" and "release" and have a seperate function that generates smaler steps and stops when the button will be released.