Trust ZYCT-202 setting up dimming via zigbee2mqtt

sorry for the slow reply.

I’ve exported this flow which is the latest version, maybe something changed. Give it a try and let me know how you get on. You might need to adjust it to suit your bulbs.

[{"id":"aaeb84d7.0184e","type":"tab","label":"Trust 202 on/off","disabled":false,"info":""},{"id":"19e86797.74df68","type":"switch","z":"aaeb84d7.0184e","name":"On, off, up, down","property":"payload.action","propertyType":"msg","rules":[{"t":"eq","v":"on","vt":"str"},{"t":"eq","v":"off","vt":"str"},{"t":"eq","v":"up-press","vt":"str"},{"t":"eq","v":"down-press","vt":"str"}],"checkall":"true","repair":true,"outputs":4,"x":790,"y":300,"wires":[["b6faf5d5.7c7418"],["74708489.50d6ec"],["39a58d72.170e02"],["203562ec.0c25ae"]]},{"id":"b6faf5d5.7c7418","type":"api-call-service","z":"aaeb84d7.0184e","name":"Globe Lamp On","server":"987de3d2.e61e3","version":1,"debugenabled":false,"service_domain":"light","service":"turn_on","entityId":"light.rgb_3_light","data":"","dataType":"json","mergecontext":"","output_location":"payload","output_location_type":"msg","mustacheAltTags":false,"x":1300,"y":100,"wires":[[]]},{"id":"74708489.50d6ec","type":"api-call-service","z":"aaeb84d7.0184e","name":"Globe Lamp Off","server":"89080ee6.7112f8","version":1,"debugenabled":false,"service_domain":"light","service":"turn_off","entityId":"light.rgb_3_light","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1300,"y":180,"wires":[[]]},{"id":"a87d8825.26ae","type":"mqtt in","z":"aaeb84d7.0184e","name":"","topic":"zigbee2mqtt/remote","qos":"2","datatype":"auto","broker":"aa4be58a.022348","x":90,"y":440,"wires":[["78e453c7.9945bc"]]},{"id":"78e453c7.9945bc","type":"json","z":"aaeb84d7.0184e","name":"","property":"payload","action":"","pretty":false,"x":350,"y":440,"wires":[["c549ca81.4567d8"]]},{"id":"c549ca81.4567d8","type":"switch","z":"aaeb84d7.0184e","name":"Action Group","property":"payload.action_group","propertyType":"msg","rules":[{"t":"eq","v":"145","vt":"str"},{"t":"eq","v":"146","vt":"str"},{"t":"eq","v":"147","vt":"str"},{"t":"eq","v":"148","vt":"str"},{"t":"eq","v":"149","vt":"str"},{"t":"eq","v":"150","vt":"str"}],"checkall":"true","repair":false,"outputs":6,"x":550,"y":440,"wires":[["19e86797.74df68"],["554d3fbd.83552"],["f971500.a059e3"],["9079cb00.7085d"],[],["dc83a52a.ebbbd"]]},{"id":"e761fcc6.126918","type":"api-call-service","z":"aaeb84d7.0184e","name":"Table Light On","server":"89080ee6.7112f8","version":1,"debugenabled":false,"service_domain":"light","service":"turn_on","entityId":"light.rgb_2_light","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1280,"y":480,"wires":[[]]},{"id":"def34a71.2e91","type":"api-call-service","z":"aaeb84d7.0184e","name":"Table Light Off","server":"89080ee6.7112f8","version":1,"debugenabled":false,"service_domain":"light","service":"turn_off","entityId":"light.rgb_2_light","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1280,"y":560,"wires":[[]]},{"id":"554d3fbd.83552","type":"switch","z":"aaeb84d7.0184e","name":"On, off, up, down","property":"payload.action","propertyType":"msg","rules":[{"t":"eq","v":"on","vt":"str"},{"t":"eq","v":"off","vt":"str"},{"t":"eq","v":"up-press","vt":"str"},{"t":"eq","v":"down-press","vt":"str"}],"checkall":"true","repair":true,"outputs":4,"x":790,"y":420,"wires":[["e761fcc6.126918"],["def34a71.2e91"],["966ab9e7.ac57f8"],["8c093f91.1bc528"]]},{"id":"f971500.a059e3","type":"switch","z":"aaeb84d7.0184e","name":"On, off, up, down","property":"payload.action","propertyType":"msg","rules":[{"t":"eq","v":"on","vt":"str"},{"t":"eq","v":"off","vt":"str"},{"t":"eq","v":"up-press","vt":"str"},{"t":"eq","v":"down-press","vt":"str"}],"checkall":"true","repair":true,"outputs":4,"x":790,"y":540,"wires":[["72a5606.e3b1ea"],["999a5e12.a27c"],["d0d25051.502bd"],["8171040e.a6a83"]]},{"id":"999a5e12.a27c","type":"api-call-service","z":"aaeb84d7.0184e","name":"Warm Lamp Off","server":"89080ee6.7112f8","version":1,"debugenabled":false,"service_domain":"light","service":"turn_off","entityId":"light.table_light","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1280,"y":920,"wires":[[]]},{"id":"72a5606.e3b1ea","type":"api-call-service","z":"aaeb84d7.0184e","name":"Warm Lamp On","server":"89080ee6.7112f8","version":1,"debugenabled":false,"service_domain":"light","service":"turn_on","entityId":"light.table_light","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1280,"y":840,"wires":[[]]},{"id":"39a58d72.170e02","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.rgb_3_light","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":1350,"y":300,"wires":[["6d04ed67.8d2ba4"]]},{"id":"203562ec.0c25ae","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.rgb_3_light","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":1350,"y":360,"wires":[["ff1f2084.d678c"]]},{"id":"6d04ed67.8d2ba4","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.rgb_3_light', brightness: brightness}\n};\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1750,"y":300,"wires":[["e0f2d5c3.4609b8"]]},{"id":"ff1f2084.d678c","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.rgb_3_light', brightness: brightness}\n};\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1750,"y":360,"wires":[["e0f2d5c3.4609b8"]]},{"id":"e0f2d5c3.4609b8","type":"api-call-service","z":"aaeb84d7.0184e","name":"Set Globe Lamp Brightness","server":"89080ee6.7112f8","version":1,"debugenabled":false,"service_domain":"light","service":"turn_on","entityId":"light.rgb_3_light","data":"","dataType":"json","mergecontext":"","output_location":"payload","output_location_type":"msg","mustacheAltTags":false,"x":2100,"y":320,"wires":[[]]},{"id":"966ab9e7.ac57f8","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.rgb_2_light","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":1330,"y":640,"wires":[["875314ca.42219"]]},{"id":"8c093f91.1bc528","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.rgb_2_light","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":1330,"y":700,"wires":[["51b44048.cefec"]]},{"id":"875314ca.42219","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.rgb_2_light', brightness: brightness}\n};\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1750,"y":640,"wires":[["a053254b.03725"]]},{"id":"51b44048.cefec","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.rgb_2_light', brightness: brightness}\n};\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1750,"y":700,"wires":[["a053254b.03725"]]},{"id":"a053254b.03725","type":"api-call-service","z":"aaeb84d7.0184e","name":"Set Table Light Brightness","server":"89080ee6.7112f8","version":1,"debugenabled":false,"service_domain":"light","service":"turn_on","entityId":"light.rgb_2_light","data":"","dataType":"json","mergecontext":"","output_location":"payload","output_location_type":"msg","mustacheAltTags":false,"x":2100,"y":660,"wires":[[]]},{"id":"d0d25051.502bd","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.table_light","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":1330,"y":1020,"wires":[["fbbacbfc.950a8"]]},{"id":"8171040e.a6a83","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.table_light","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":1330,"y":1080,"wires":[["a4f53a5c.f44c9"]]},{"id":"fbbacbfc.950a8","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.table_light', brightness: brightness}\n};\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1750,"y":1020,"wires":[["b61b351c.c7bb2"]]},{"id":"a4f53a5c.f44c9","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.table_light', brightness: brightness}\n};\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1750,"y":1080,"wires":[["b61b351c.c7bb2"]]},{"id":"b61b351c.c7bb2","type":"api-call-service","z":"aaeb84d7.0184e","name":"Set Warm Lamp Brightness","server":"89080ee6.7112f8","version":1,"debugenabled":false,"service_domain":"light","service":"turn_on","entityId":"light.table_light","data":"","dataType":"json","mergecontext":"","output_location":"payload","output_location_type":"msg","mustacheAltTags":false,"x":2100,"y":1040,"wires":[[]]},{"id":"dc83a52a.ebbbd","type":"switch","z":"aaeb84d7.0184e","name":"On, off, up, down","property":"payload.action","propertyType":"msg","rules":[{"t":"eq","v":"on","vt":"str"},{"t":"eq","v":"off","vt":"str"},{"t":"eq","v":"up-press","vt":"str"},{"t":"eq","v":"down-press","vt":"str"}],"checkall":"true","repair":true,"outputs":4,"x":790,"y":680,"wires":[["b0677ae6.cf7e28"],["c1933d28.5d41d"],[],[]]},{"id":"b0677ae6.cf7e28","type":"api-call-service","z":"aaeb84d7.0184e","name":"Group On","server":"89080ee6.7112f8","version":1,"debugenabled":false,"service_domain":"light","service":"turn_on","entityId":"group.living_room","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1260,"y":1220,"wires":[[]]},{"id":"c1933d28.5d41d","type":"api-call-service","z":"aaeb84d7.0184e","name":"Group Off","server":"89080ee6.7112f8","version":1,"debugenabled":false,"service_domain":"light","service":"turn_off","entityId":"group.living_room","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1260,"y":1280,"wires":[[]]},{"id":"9079cb00.7085d","type":"switch","z":"aaeb84d7.0184e","name":"On, off, up, down","property":"payload.action","propertyType":"msg","rules":[{"t":"eq","v":"on","vt":"str"},{"t":"eq","v":"off","vt":"str"},{"t":"eq","v":"up-press","vt":"str"},{"t":"eq","v":"down-press","vt":"str"}],"checkall":"true","repair":true,"outputs":4,"x":310,"y":1300,"wires":[["4366473b.e01cb"],["d443cf34.6c6db8"],["5c4df6ef.d0fac"],["49d5c38.4efd8bc"]]},{"id":"4366473b.e01cb","type":"api-call-service","z":"aaeb84d7.0184e","name":"Landing Light On","server":"89080ee6.7112f8","version":1,"debugenabled":false,"service_domain":"light","service":"turn_on","entityId":"light.landing_light_light","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":710,"y":1540,"wires":[[]]},{"id":"d443cf34.6c6db8","type":"api-call-service","z":"aaeb84d7.0184e","name":"Landing Light Off","server":"89080ee6.7112f8","version":1,"debugenabled":false,"service_domain":"light","service":"turn_off","entityId":"light.landing_light_light","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":710,"y":1600,"wires":[[]]},{"id":"5c4df6ef.d0fac","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.landing_light_light","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":770,"y":1660,"wires":[["583ff304.973c44"]]},{"id":"49d5c38.4efd8bc","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.landing_light_light","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":770,"y":1720,"wires":[["ed38cc6d.39ac58"]]},{"id":"583ff304.973c44","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.landing_light_light', brightness: brightness}\n};\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1130,"y":1660,"wires":[["aefecb05.6f9f48"]]},{"id":"ed38cc6d.39ac58","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.landing_light_light', brightness: brightness}\n};\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1130,"y":1720,"wires":[["aefecb05.6f9f48"]]},{"id":"aefecb05.6f9f48","type":"api-call-service","z":"aaeb84d7.0184e","name":"Set Table Light Brightness","server":"89080ee6.7112f8","version":1,"debugenabled":false,"service_domain":"light","service":"turn_on","entityId":"light.landing_light_light","data":"","dataType":"json","mergecontext":"","output_location":"payload","output_location_type":"msg","mustacheAltTags":false,"x":1420,"y":1680,"wires":[[]]},{"id":"987de3d2.e61e3","type":"server","name":"Home Assistant","addon":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,"cacheJson":true},{"id":"aa4be58a.022348","type":"mqtt-broker","name":"Mosquitto","broker":"192.168.1.193","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":""}]

@ xaviml Hello Xavi, I have the on/off working for multiple lights using “constrain_input_select: input_select.action_group,64957”, so selecting the device by the action groupe code. But changing the brightness is not working. I tried to add the actions, but the it stops working.

Trust_controller_hoeklamp:
  module: controllerx
  class: ZYCT202LightController
  controller: sensor.trust_remote_action
  integration: z2m
  light: light.ikea_hoeklamp
  constrain_input_select: input_select.action_group,64958

Hi @Roger_Valkering,

I would need to see the logs to know what is happening in your case. The configuration looks good to me. Please, open a GitHub issue with the Question form so I can easily track it and help you out.

Regards,
Xavi M.