Increase brightness

hi, i need a function that helps me to increase the brightness value when i push a switch on the xiaomi.
at the first click the light turns on and starts from +10 and every time I press it increases by 10.
naturally the maximum value of the increase is 254. when
if it reaches this value the brightness locks to the maximum.
thanks to those who want to help me

[{“id”:“9e50177d.bc0da8”,“type”:“switch”,“z”:“81035877.1bbba8”,“name”:“Comodini left”,“property”:“payload.entity_id”,“propertyType”:“msg”,“rules”:[{“t”:“eq”,“v”:“binary_sensor.wall_switch_left_158d0001e0bf81”,“vt”:“str”}],“checkall”:“true”,“repair”:true,“outputs”:1,“x”:230,“y”:1100,“wires”:[[“c9494890.c5d788”]]},{“id”:“c9494890.c5d788”,“type”:“switch”,“z”:“81035877.1bbba8”,“name”:“left”,“property”:“payload.event.click_type”,“propertyType”:“msg”,“rules”:[{“t”:“eq”,“v”:“single”,“vt”:“str”}],“checkall”:“true”,“repair”:true,“outputs”:1,“x”:490,“y”:1100,“wires”:[]},{“id”:“7302fdfc.6e4124”,“type”:“server-events”,“z”:“81035877.1bbba8”,“name”:“HASrv”,“server”:“28bd13bd.8d60ec”,“event_type”:“xiaomi_aqara.click”,“exposeToHomeAssistant”:false,“haConfig”:[{“property”:“name”,“value”:“”},{“property”:“icon”,“value”:“”}],“waitForRunning”:false,“x”:70,“y”:20,“wires”:[[“73f60aa.f2290f4”,“f1373fa9.162d8”,“d4b9d0dc.54208”,“858aaa92.a2eed8”,“6b643a14.8de6f4”,“4aea2853.fa7a78”,“9e50177d.bc0da8”,“d6e4f704.2421a8”,“82b3d2f2.35a2c”,“f556c85e.bb71a8”]]},{“id”:“28bd13bd.8d60ec”,“type”:“server”,“z”:“”,“name”:“Home Assistant”,“legacy”:false,“addon”:true,“rejectUnauthorizedCerts”:true,“ha_boolean”:“y|yes|true|on|home|open”,“connectionDelay”:true,“cacheJson”:true}]

I am not going to write it for you (maybe someone might).

What have you tried?
Where are your nodes?

You’ve also written 330 posts, you should know to put code blocks around your JSON output.

thank you :slight_smile:

For my Aquara cube I found the following solution:

  • have an input that tricggers everything (your Xiaomi switch)
  • When the trigger is fired, trigger the poll of the old light level from the lamp
  • feed that into a function block that increases this by 10 and checks for the limits
  • feed that into an output block that sends the new brightness level to your lamp

copy and paste this for a decreasing line, then obviously reducing by ten and checking for the lower limits.

could you please write the json text of the flow?

Sorry, but I cannot do that.

[{"id":"d6e4f704.2421a8","type":"switch","z":"81035877.1bbba8","name":"Comodini right","property":"payload.entity_id","propertyType":"msg","rules":[{"t":"eq","v":"binary_sensor.wall_switch_right_158d0001e0bf81","vt":"str"}],"checkall":"true","repair":true,"outputs":1,"x":280,"y":1700,"wires":[["c9c2a1ad.14611"]]},{"id":"c9c2a1ad.14611","type":"switch","z":"81035877.1bbba8","name":"right","property":"payload.event.click_type","propertyType":"msg","rules":[{"t":"eq","v":"single","vt":"str"}],"checkall":"true","repair":true,"outputs":1,"x":430,"y":1700,"wires":[["3f0f65c9.bf10da"]]},{"id":"5974cd1.0e4fd34","type":"inject","z":"81035877.1bbba8","name":"decrement","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":"","topic":"","payload":"","payloadType":"date","x":600,"y":1740,"wires":[["168bd08a.292a8f"]]},{"id":"3b54d9d1.db9d16","type":"inject","z":"81035877.1bbba8","name":"increment","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":"","topic":"","payload":"","payloadType":"date","x":600,"y":1700,"wires":[["3f0f65c9.bf10da"]]},{"id":"e024c1bd.ee72e","type":"inject","z":"81035877.1bbba8","name":"reset","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":"","topic":"","payload":"","payloadType":"date","x":590,"y":1780,"wires":[["6d1b4764.f3fdc8"]]},{"id":"3f0f65c9.bf10da","type":"function","z":"81035877.1bbba8","name":"msg object","func":"msg.increment = 10;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":770,"y":1700,"wires":[["a9b48fa4.9e967"]]},{"id":"6d1b4764.f3fdc8","type":"function","z":"81035877.1bbba8","name":"msg object","func":"msg.reset = true;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":770,"y":1780,"wires":[["a9b48fa4.9e967"]]},{"id":"168bd08a.292a8f","type":"function","z":"81035877.1bbba8","name":"msg object","func":"msg.decrement = 10;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":770,"y":1740,"wires":[["a9b48fa4.9e967"]]},{"id":"a9b48fa4.9e967","type":"counter","z":"81035877.1bbba8","name":"","init":"0","step":1,"lower":"0","upper":"254","mode":"increment","outputs":"1","x":960,"y":1720,"wires":[["4265c9fb.732cf8","bcccfc1.302bf"]]},{"id":"4265c9fb.732cf8","type":"debug","z":"81035877.1bbba8","name":"message","active":true,"console":"false","complete":"true","x":1120,"y":1720,"wires":[]},{"id":"bcccfc1.302bf","type":"switch","z":"81035877.1bbba8","name":"Brightess Maximum","property":"count","propertyType":"msg","rules":[{"t":"lte","v":"254","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":1150,"y":1760,"wires":[["76438a6d.b9c6e4","b6f09ac1.670d68","e7e83a90.f0c808"]]},{"id":"dc2db52b.2d01c8","type":"link in","z":"81035877.1bbba8","name":"","links":["55bd4705.62ef08"],"x":475,"y":1780,"wires":[["6d1b4764.f3fdc8"]]},{"id":"76438a6d.b9c6e4","type":"api-call-service","z":"81035877.1bbba8","name":"light.letto_matteo","server":"28bd13bd.8d60ec","version":1,"debugenabled":false,"service_domain":"light","service":"turn_on","entityId":"light.letto_matteo","data":"{\"brightness\":\"{{count}}\",\"color_temp\":333}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1450,"y":1760,"wires":[[]]},{"id":"b6f09ac1.670d68","type":"api-call-service","z":"81035877.1bbba8","name":"light.bed_side_lamp_matteo","server":"28bd13bd.8d60ec","version":1,"debugenabled":false,"service_domain":"light","service":"turn_on","entityId":"light.bed_side_lamp_matteo","data":"{\"brightness\":\"{{count}}\",\"rgb_color\":[255,200,36]}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1480,"y":1820,"wires":[[]]},{"id":"1974afb4.764a2","type":"api-call-service","z":"81035877.1bbba8","name":"light.bed_side_lamp_matteo","server":"28bd13bd.8d60ec","version":1,"debugenabled":false,"service_domain":"light","service":"turn_on","entityId":"light.bed_side_lamp_matteo","data":"{\"color_temp\":333}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1480,"y":1940,"wires":[[]]},{"id":"e7e83a90.f0c808","type":"stoptimer","z":"81035877.1bbba8","d":true,"duration":"50","units":"Millisecond","payloadtype":"num","payloadval":"0","name":"","x":1460,"y":1880,"wires":[["1974afb4.764a2","efdf77dd.7832c8"],[]]},{"id":"efdf77dd.7832c8","type":"api-call-service","z":"81035877.1bbba8","name":"light.letto_matteo","server":"28bd13bd.8d60ec","version":1,"debugenabled":false,"service_domain":"light","service":"turn_on","entityId":"light.letto_matteo","data":"{\"color_temp\":333}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1450,"y":1980,"wires":[[]]},{"id":"28bd13bd.8d60ec","type":"server","z":"","name":"Home Assistant","legacy":false,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true}]