@martinhjelmare
I tried your sketch as is, just to try one leg for the RGB Led, but I'm not getting the expected result. When I change the brightness from the HA UI slider, the node gets the correct value, but...
send: 12-12-0-0 s=255,c=3,t=15,pt=2,l=2,sg=0,st=ok:0
send: 12-12-0-0 s=255,c=0,t=17,pt=0,l=5,sg=0,st=ok:1.5.3
send: 12-12-0-0 s=255,c=3,t=6,pt=1,l=1,sg=0,st=ok:0
sensor started, id=12, parent=0, distance=1
send: 12-12-0-0 s=1,c=0,t=26,pt=0,l=0,sg=0,st=ok:
send: 12-12-0-0 s=255,c=3,t=11,pt=0,l=11,sg=0,st=ok:DimmableLED
send: 12-12-0-0 s=255,c=3,t=12,pt=0,l=3,sg=0,st=ok:1.1
send: 12-12-0-0 s=1,c=2,t=3,pt=0,l=0,sg=0,st=ok:
send: 12-12-0-0 s=1,c=1,t=2,pt=2,l=2,sg=0,st=ok:0
send: 12-12-0-0 s=1,c=1,t=3,pt=2,l=2,sg=0,st=ok:0
send: 12-12-0-0 s=1,c=1,t=40,pt=0,l=6,sg=0,st=ok:ffffff
read: 0-0-12 s=1,c=1,t=2,pt=0,l=1,sg=0:1
Changing level to 100, from 0
send: 12-12-0-0 s=1,c=1,t=2,pt=2,l=2,sg=0,st=ok:1
send: 12-12-0-0 s=1,c=1,t=3,pt=2,l=2,sg=0,st=ok:100
read: 0-0-12 s=1,c=1,t=3,pt=0,l=2,sg=0:17 // <- Here I modified brightness
Changing level to 100, from 100
send: 12-12-0-0 s=1,c=1,t=2,pt=2,l=2,sg=0,st=ok:1
send: 12-12-0-0 s=1,c=1,t=3,pt=2,l=2,sg=0,st=ok:100
read: 0-0-12 s=1,c=1,t=3,pt=0,l=1,sg=0:9 // <- Here too
Changing level to 100, from 100
send: 12-12-0-0 s=1,c=1,t=2,pt=2,l=2,sg=0,st=ok:1
send: 12-12-0-0 s=1,c=1,t=3,pt=2,l=2,sg=0,st=ok:100
As you see, no matter what level receives, It goes to 100 forever.
And if you try to move the brightness slider more over to the right (or the left to reduce), the values sometimes get higher than 100 (or -100), despite of the "clipping" method of the sketch.
EDIT:
Made a few changes to the code, to find what's failing, and I think is the way HA sends commands to the node;
...
if (message.type == V_DIMMER) {
// Retrieve the power or dim level from the incoming request message
int requestedLevel = atoi(message.data);
Serial.print("Received: ");
Serial.println(message.data);
Serial.print("Bright: ");
Serial.println(requestedLevel);
...
And the log from the sensor:
send: 12-12-0-0 s=255,c=3,t=15,pt=2,l=2,sg=0,st=ok:0
send: 12-12-0-0 s=255,c=0,t=17,pt=0,l=5,sg=0,st=ok:1.5.3
send: 12-12-0-0 s=255,c=3,t=6,pt=1,l=1,sg=0,st=ok:0
sensor started, id=12, parent=0, distance=1
send: 12-12-0-0 s=1,c=0,t=26,pt=0,l=0,sg=0,st=ok:
send: 12-12-0-0 s=255,c=3,t=11,pt=0,l=11,sg=0,st=ok:DimmableLED
send: 12-12-0-0 s=255,c=3,t=12,pt=0,l=3,sg=0,st=ok:1.1
send: 12-12-0-0 s=1,c=2,t=3,pt=0,l=0,sg=0,st=ok:
read: 0-0-12 s=1,c=1,t=3,pt=0,l=3,sg=0:100
Received: 100mableLED
Bright: 100
Changing level to 100, from 0
send: 12-12-0-0 s=1,c=1,t=3,pt=2,l=2,sg=0,st=ok:100
send: 12-12-0-0 s=1,c=1,t=2,pt=2,l=2,sg=0,st=ok:1
send: 12-12-0-0 s=1,c=1,t=3,pt=2,l=2,sg=0,st=ok:100
send: 12-12-0-0 s=1,c=1,t=40,pt=0,l=6,sg=0,st=ok:ffffff
read: 0-0-12 s=1,c=1,t=3,pt=0,l=2,sg=0:45
Received: 450mableLED
Bright: 450
Changing level to 100, from 100
send: 12-12-0-0 s=1,c=1,t=3,pt=2,l=2,sg=0,st=ok:100
Seems there is a string of the message (sketch name maybe) messing with the brightness data.