This is in light.yaml
- platform: mqtt
schema: json
name: 'Eettafel'
state_topic: 'huis/woonkamer/lamp/eettafel/state'
command_topic: 'huis/woonkamer/lamp/eettafel/set'
brightness: true
brightness_scale: 32
retain: false
optimistic: true
Then here is my subflow in NodeRed, send your mqtt commands there and make sure the same values go to the state_topic.
[{"id":"2f1fdc8a.e41924","type":"subflow","name":"KaKu dimmer","info":"","category":"","in":[{"x":40,"y":200,"wires":[{"id":"aa997461.f119f8"}]}],"out":[{"x":1140,"y":140,"wires":[{"id":"47bb4f6c.a274d","port":0}]}],"env":[],"inputLabels":["Input"],"outputLabels":["Debug"]},{"id":"47bb4f6c.a274d","type":"delay","z":"2f1fdc8a.e41924","name":"","pauseType":"rate","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":1030,"y":200,"wires":[["63ca8690.a23778"]]},{"id":"63ca8690.a23778","type":"udp out","z":"2f1fdc8a.e41924","name":"ICS-1000","addr":"192.168.1.202","iface":"","port":"9760","ipv":"udp4","outport":"","base64":false,"multicast":"broad","x":1180,"y":200,"wires":[]},{"id":"a6b2afe5.327b1","type":"function","z":"2f1fdc8a.e41924","name":"On/brightness magic stuff","func":"b = msg.payload.brightness;\ns = msg.payload.state;\nr = msg.payload.r;\nd = msg.payload.d;\nif (b === 0){\n b = 1;\n}\nx = '001,!R' + r + 'D' + d + 'FdP' + b + '|Home|Assistant|';\nmsg.payload = x;\nreturn msg;","outputs":1,"noerr":0,"x":590,"y":260,"wires":[["47bb4f6c.a274d"]]},{"id":"aa997461.f119f8","type":"switch","z":"2f1fdc8a.e41924","name":"Off or not","property":"payload.state","propertyType":"msg","rules":[{"t":"eq","v":"OFF","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":140,"y":200,"wires":[["322b4058.41302"],["415e7c84.9747f4"]]},{"id":"322b4058.41302","type":"function","z":"2f1fdc8a.e41924","name":"OFF magic stuff","func":"r = msg.payload.r;\nd = msg.payload.d;\nx = '001,!R' + r + 'D' + d + 'F0' + '|Home|Assistant|';\nmsg.payload = x;\nreturn msg;\n","outputs":1,"noerr":0,"x":320,"y":160,"wires":[["47bb4f6c.a274d"]]},{"id":"415e7c84.9747f4","type":"switch","z":"2f1fdc8a.e41924","name":"Brightness or not","property":"payload.brightness","propertyType":"msg","rules":[{"t":"null"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":330,"y":240,"wires":[["9a5a5db4.0cd45"],["a6b2afe5.327b1"]]},{"id":"9a5a5db4.0cd45","type":"change","z":"2f1fdc8a.e41924","name":"","rules":[{"t":"set","p":"payload.brightness","pt":"msg","to":"9","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":580,"y":200,"wires":[["a6b2afe5.327b1"]]}]