MySensors RGB color picker

Hi,

I’m using MySensors to get temperatures around the house, and to control a dimmable led light.

Next up is to add a home made LED lamp with a extra RGB strip, so i wanted to use the MySensors S_RGBW_LIGHT type,

According to mysensors - component its supporter.
After uploading a sketch to my arduino its visible in HA.
i can controle the W (white) from a scale from 0 to 100. no problem.

But where is the RGB color picker ? (see screenshot)
Also tried the S_RGB_LIGHT type, same result.

Greetings
Bram

1 Like

Hi!

It’s weird that you have 0 as value for V_RGBW. It should be an eight character hex string. What are you reporting as value for this type in your sketch? Any errors in the home assistant log?

Brightness is not the same as white value in home assistant.

Ah, my bad, added a “send msg” as seen in de HA documents:

Made no change.

No errors in the HA log.

You have to turn the light on to get the color selector. Did you test that after setting the correct value?

Yes i turned it on, but no selector appeared.
Tested this before and after the change

The sketch i used:

#define MY_DEBUG
#define MY_RADIO_NRF24


#define SN   "RGBW Light"
#define SV   "1.0"

#include <MySensors.h>
#define SENSOR_ID 1


MyMessage rgb_msg( SENSOR_ID, V_RGBW );
MyMessage status_msg( SENSOR_ID, V_STATUS );
MyMessage dimmer_msg( SENSOR_ID, V_DIMMER );
    
void presentation() 
{
  // Present sketch (name, version)
  sendSketchInfo(SN, SV);        
       
  // Register sensors (id, type, description, ack back)
  present(SENSOR_ID, S_RGBW_LIGHT, SN, true);

  // get old values if this is just a restart
  request(SENSOR_ID, V_RGBW);
}

void setup() {  
  Serial.println("Waiting for messages...");  
}

void loop()
{

  // Send msg on startup
  static bool first_message_sent = false;
  if ( first_message_sent == false ) {
    Serial.println( "Sending initial state..." );
    send_startup();
    first_message_sent = true;
  }
  
}

void send_startup(){
   send( rgb_msg.set("ff0000ff") );
   send( dimmer_msg.set(0) );
   send( status_msg.set(0) );
}

// callback function for incoming messages
void receive(const MyMessage &message) {

  // DEBUG
  Serial.print("Got a message - ");
  Serial.print("Messagetype is: ");
  Serial.println(message.type);
  // END DEBUG

  // Acknoledgment
  if (message.isAck()) {
    
    Serial.println("Got ack from gateway");
    
  } else if (message.type == V_DIMMER) {
    
      Serial.println("Dimming to ");
      Serial.println(message.getInt());
      send(dimmer_msg.set(message.getInt()));

      // Do dimmer stuff here
      
  } else if (message.type == V_STATUS) {
    
    Serial.print("Turning light ");
    Serial.println(message.getInt());
    send(status_msg.set(message.getInt()));

    // Do On/Off stuff here

  } else if (message.type == V_RGB) {  
      
    Serial.println("RGBW!");
    Serial.println(message.getLong());
    send(rgb_msg.set(message.getLong()));

    // Set color here
    
  }  

}

Can you post a debug level log from HA, after start of the node? Use the following logger config:

logger:
  default: info
  logs:
    homeassistant.components.mysensors: debug
    homeassistant.components.light.mysensors: debug
    mysensors.mysensors: debug

and set debug to true in mysensors config:

mysensors:
...
  debug: true

A serial log from the node would also be good.

Edit: I see a problem in you sketch, I think. You convert to long and send that back when receiving a V_RGBW message. You should send a character array, and you should keep the 8 character hex format. You can look at the example sketch for mysensors 1.5 in the docs for how I’ve done that. There’s probably other ways of doing it too.

Changed the code to store and send a char[9].
char 8 gave a strange response: FF0000FFnn*#

HA still shows the correct given value, but no color picker

Feedback from node (startup):

0 MCO:BGN:INIT NODE,CP=RNNNA--,VER=2.1.1
3 TSM:INIT
4 TSF:WUR:MS=0
11 TSM:INIT:TSP OK
13 TSF:SID:OK,ID=17
14 TSM:FPAR
51 TSF:MSG:SEND,17-17-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
413 TSF:MSG:READ,0-0-17,s=255,c=3,t=8,pt=1,l=1,sg=0:0
418 TSF:MSG:FPAR OK,ID=0,D=1
2058 TSM:FPAR:OK
2059 TSM:ID
2060 TSM:ID:OK
2062 TSM:UPL
2065 TSF:MSG:SEND,17-17-0-0,s=255,c=3,t=24,pt=1,l=1,sg=0,ft=0,st=OK:1
2074 TSF:MSG:READ,0-0-17,s=255,c=3,t=25,pt=1,l=1,sg=0:1
2079 TSF:MSG:PONG RECV,HP=1
2082 TSM:UPL:OK
2083 TSM:READY:ID=17,PAR=0,DIS=1
2088 TSF:MSG:SEND,17-17-0-0,s=255,c=3,t=15,pt=6,l=2,sg=0,ft=0,st=OK:0100
2096 TSF:MSG:READ,0-0-17,s=255,c=3,t=15,pt=6,l=2,sg=0:0100
2103 TSF:MSG:SEND,17-17-0-0,s=255,c=0,t=17,pt=0,l=5,sg=0,ft=0,st=OK:2.1.1
2111 TSF:MSG:SEND,17-17-0-0,s=255,c=3,t=6,pt=1,l=1,sg=0,ft=0,st=OK:0
2146 TSF:MSG:READ,0-0-17,s=255,c=3,t=6,pt=0,l=1,sg=0:M
2153 TSF:MSG:SEND,17-17-0-0,s=255,c=3,t=11,pt=0,l=10,sg=0,ft=0,st=OK:RGBW Light
2162 TSF:MSG:SEND,17-17-0-0,s=255,c=3,t=12,pt=0,l=3,sg=0,ft=0,st=OK:1.0
2171 TSF:MSG:SEND,17-17-0-0,s=1,c=0,t=27,pt=0,l=10,sg=0,ft=0,st=OK:RGBW Light
2180 TSF:MSG:SEND,17-17-0-0,s=1,c=2,t=41,pt=0,l=0,sg=0,ft=0,st=OK:
2186 MCO:REG:REQ
2192 TSF:MSG:SEND,17-17-0-0,s=255,c=3,t=26,pt=1,l=1,sg=0,ft=0,st=OK:2
2198 TSF:MSG:READ,0-0-17,s=1,c=0,t=27,pt=0,l=10,sg=0:RGBW Light
2204 TSF:MSG:ACK
Got a message - Messagetype is: 27
Got ack from gateway
2206 TSF:MSG:READ,0-0-17,s=255,c=3,t=27,pt=1,l=1,sg=0:1
2215 MCO:PIM:NODE REG=1
2217 MCO:BGN:STP
Waiting for messages...
2220 MCO:BGN:INIT OK,TSP=1
Sending initial state...
2226 TSF:MSG:SEND,17-17-0-0,s=1,c=1,t=41,pt=0,l=8,sg=0,ft=0,st=OK:FF0000FF
2235 TSF:MSG:SEND,17-17-0-0,s=1,c=1,t=3,pt=2,l=2,sg=0,ft=0,st=OK:0
2242 TSF:MSG:SEND,17-17-0-0,s=1,c=1,t=2,pt=2,l=2,sg=0,ft=0,st=OK:0
2298 TSF:MSG:READ,0-0-17,s=1,c=1,t=41,pt=0,l=8,sg=0:FF0000FF
Got a message - Messagetype is: 41

After AH command

30654 TSF:MSG:READ,0-0-17,s=1,c=1,t=2,pt=0,l=1,sg=0:1
Got a message - Messagetype is: 2
Turning light 1
30661 TSF:MSG:SEND,17-17-0-0,s=1,c=1,t=2,pt=2,l=2,sg=0,ft=0,st=OK:1
30669 TSF:MSG:READ,0-0-17,s=1,c=1,t=3,pt=0,l=2,sg=0:45
Got a message - Messagetype is: 3
Dimming to 
45
30676 TSF:MSG:SEND,17-17-0-0,s=1,c=1,t=3,pt=2,l=2,sg=0,ft=0,st=OK:45

HA log on node connect:

17-03-19 12:38:39 DEBUG (Thread-14) [mysensors.mysensors] n:0 c:255 t:3 s:9 p:TSF:MSG:READ,17-17-255,s=255,c=3,t=7,pt=0,l=0,sg=0:
17-03-19 12:38:39 DEBUG (Thread-14) [mysensors.mysensors] n:0 c:255 t:3 s:9 p:TSF:MSG:BC
17-03-19 12:38:39 DEBUG (Thread-14) [mysensors.mysensors] n:0 c:255 t:3 s:9 p:TSF:MSG:FPAR REQ,ID=17
17-03-19 12:38:39 DEBUG (Thread-14) [mysensors.mysensors] n:0 c:255 t:3 s:9 p:TSF:PNG:SEND,TO=0
17-03-19 12:38:39 DEBUG (Thread-14) [mysensors.mysensors] n:0 c:255 t:3 s:9 p:TSF:CKU:OK
17-03-19 12:38:39 DEBUG (Thread-14) [mysensors.mysensors] n:0 c:255 t:3 s:9 p:TSF:MSG:GWL OK
17-03-19 12:38:39 DEBUG (Thread-14) [mysensors.mysensors] n:0 c:255 t:3 s:9 p:TSF:MSG:SEND,0-0-17-17,s=255,c=3,t=8,pt=1,l=1,sg=0,ft=0,st=OK:0
17-03-19 12:38:41 DEBUG (Thread-14) [mysensors.mysensors] n:0 c:255 t:3 s:9 p:TSF:MSG:READ,17-17-0,s=255,c=3,t=24,pt=1,l=1,sg=0:1
17-03-19 12:38:41 DEBUG (Thread-14) [mysensors.mysensors] n:0 c:255 t:3 s:9 p:TSF:MSG:PINGED,ID=17,HP=1
17-03-19 12:38:41 DEBUG (Thread-14) [mysensors.mysensors] n:0 c:255 t:3 s:9 p:TSF:MSG:SEND,0-0-17-17,s=255,c=3,t=25,pt=1,l=1,sg=0,ft=0,st=OK:1
17-03-19 12:38:41 DEBUG (Thread-14) [mysensors.mysensors] n:0 c:255 t:3 s:9 p:TSF:MSG:READ,17-17-0,s=255,c=3,t=15,pt=6,l=2,sg=0:0100
17-03-19 12:38:41 DEBUG (Thread-14) [mysensors.mysensors] n:0 c:255 t:3 s:9 p:TSF:MSG:SEND,0-0-17-17,s=255,c=3,t=15,pt=6,l=2,sg=0,ft=0,st=OK:0100
17-03-19 12:38:41 DEBUG (Thread-14) [mysensors.mysensors] n:0 c:255 t:3 s:9 p:TSF:MSG:READ,17-17-0,s=255,c=0,t=17,pt=0,l=5,sg=0:2.1.1
17-03-19 12:38:41 DEBUG (Thread-14) [mysensors.mysensors] n:0 c:255 t:3 s:9 p:TSF:MSG:READ,17-17-0,s=255,c=3,t=6,pt=1,l=1,sg=0:0
17-03-19 12:38:41 DEBUG (Thread-14) [mysensors.mysensors] n:0 c:255 t:3 s:9 p:TSF:MSG:SEND,0-0-17-17,s=255,c=3,t=6,pt=0,l=1,sg=0,ft=0,st=OK:M
17-03-19 12:38:41 DEBUG (Thread-14) [mysensors.mysensors] n:0 c:255 t:3 s:9 p:TSF:MSG:READ,17-17-0,s=255,c=3,t=11,pt=0,l=10,sg=0:RGBW Light
17-03-19 12:38:41 DEBUG (Thread-14) [homeassistant.components.mysensors] Update sensor_update: node 17
17-03-19 12:38:41 DEBUG (Thread-4) [homeassistant.components.light.mysensors] RGBW Light 17 1: value_type 41, value = FF0000FF
17-03-19 12:38:41 DEBUG (Thread-4) [homeassistant.components.light.mysensors] RGBW Light 17 1: value_type 2, value = 0
17-03-19 12:38:41 DEBUG (Thread-4) [homeassistant.components.light.mysensors] RGBW Light 17 1: value_type 3, value = 0
17-03-19 12:38:41 DEBUG (Thread-14) [mysensors.mysensors] n:0 c:255 t:3 s:9 p:TSF:MSG:READ,17-17-0,s=255,c=3,t=12,pt=0,l=3,sg=0:1.0
17-03-19 12:38:41 DEBUG (Thread-14) [homeassistant.components.mysensors] Update sensor_update: node 17
17-03-19 12:38:41 DEBUG (Thread-10) [homeassistant.components.light.mysensors] RGBW Light 17 1: value_type 41, value = FF0000FF
17-03-19 12:38:41 DEBUG (Thread-10) [homeassistant.components.light.mysensors] RGBW Light 17 1: value_type 2, value = 0
17-03-19 12:38:41 DEBUG (Thread-10) [homeassistant.components.light.mysensors] RGBW Light 17 1: value_type 3, value = 0
17-03-19 12:38:41 DEBUG (Thread-14) [mysensors.mysensors] n:0 c:255 t:3 s:9 p:TSF:MSG:READ,17-17-0,s=1,c=0,t=27,pt=0,l=10,sg=0:RGBW Light
17-03-19 12:38:41 DEBUG (Thread-14) [mysensors.mysensors] n:0 c:255 t:3 s:9 p:TSF:MSG:ACK REQ
17-03-19 12:38:41 DEBUG (Thread-14) [mysensors.mysensors] n:0 c:255 t:3 s:9 p:TSF:MSG:SEND,0-0-17-17,s=1,c=0,t=27,pt=0,l=10,sg=0,ft=0,st=OK:RGBW Light
17-03-19 12:38:41 WARNING (Thread-14) [mysensors.mysensors] child_id 1 already exists in children of node 17, cannot add child
17-03-19 12:38:41 DEBUG (Thread-14) [mysensors.mysensors] n:0 c:255 t:3 s:9 p:TSF:MSG:READ,17-17-0,s=1,c=2,t=41,pt=0,l=0,sg=0:
17-03-19 12:38:41 DEBUG (Thread-14) [mysensors.mysensors] n:0 c:255 t:3 s:9 p:TSF:MSG:READ,17-17-0,s=255,c=3,t=26,pt=1,l=1,sg=0:2
17-03-19 12:38:41 DEBUG (Thread-14) [mysensors.mysensors] n:0 c:255 t:3 s:9 p:TSF:MSG:SEND,0-0-17-17,s=255,c=3,t=27,pt=1,l=1,sg=0,ft=0,st=OK:1
17-03-19 12:38:41 DEBUG (Thread-14) [mysensors.mysensors] n:0 c:255 t:3 s:9 p:TSF:MSG:READ,17-17-0,s=1,c=1,t=41,pt=0,l=8,sg=0:FF0000FF
17-03-19 12:38:41 DEBUG (Thread-14) [homeassistant.components.mysensors] Update sensor_update: node 17
17-03-19 12:38:41 DEBUG (Thread-5) [homeassistant.components.light.mysensors] RGBW Light 17 1: value_type 41, value = FF0000FF
17-03-19 12:38:41 DEBUG (Thread-5) [homeassistant.components.light.mysensors] RGBW Light 17 1: value_type 2, value = 0
17-03-19 12:38:41 DEBUG (Thread-5) [homeassistant.components.light.mysensors] RGBW Light 17 1: value_type 3, value = 0
17-03-19 12:38:41 DEBUG (Thread-14) [mysensors.mysensors] n:0 c:255 t:3 s:9 p:TSF:MSG:READ,17-17-0,s=1,c=1,t=3,pt=2,l=2,sg=0:0
17-03-19 12:38:41 DEBUG (Thread-14) [homeassistant.components.mysensors] Update sensor_update: node 17
17-03-19 12:38:41 DEBUG (Thread-3) [homeassistant.components.light.mysensors] RGBW Light 17 1: value_type 41, value = FF0000FF
17-03-19 12:38:41 DEBUG (Thread-3) [homeassistant.components.light.mysensors] RGBW Light 17 1: value_type 2, value = 0
17-03-19 12:38:41 DEBUG (Thread-3) [homeassistant.components.light.mysensors] RGBW Light 17 1: value_type 3, value = 0
17-03-19 12:38:41 DEBUG (Thread-14) [mysensors.mysensors] n:0 c:255 t:3 s:9 p:TSF:MSG:READ,17-17-0,s=1,c=1,t=2,pt=2,l=2,sg=0:0
17-03-19 12:38:41 DEBUG (Thread-14) [homeassistant.components.mysensors] Update sensor_update: node 17
17-03-19 12:38:41 DEBUG (Thread-12) [homeassistant.components.light.mysensors] RGBW Light 17 1: value_type 41, value = FF0000FF
17-03-19 12:38:41 DEBUG (Thread-12) [homeassistant.components.light.mysensors] RGBW Light 17 1: value_type 2, value = 0
17-03-19 12:38:41 DEBUG (Thread-12) [homeassistant.components.light.mysensors] RGBW Light 17 1: value_type 3, value = 0
17-03-19 12:38:41 DEBUG (Thread-14) [mysensors.mysensors] n:0 c:255 t:3 s:9 p:TSF:MSG:SEND,0-0-17-17,s=1,c=1,t=41,pt=0,l=8,sg=0,ft=0,st=OK:FF0000FF

Nothing stands out from the logs. I’d like to check the child type of your child. Do you use JSON persistence? Could you post the contents of the JSON persistence file?

Json:

{
	"0": {
		"sensor_id": 0,
		"sketch_version": null,
		"children": {},
		"type": 18,
		"protocol_version": "2.1.1",
		"sketch_name": null,
		"battery_level": 0
	},
	"17": {
		"sensor_id": 17,
		"sketch_version": "1.0",
		"children": {
			"1": {
				"id": 1,
				"values": {
					"41": "FF0000FF",
					"2": "0",
					"3": "0"
				},
				"description": "RGBW Light",
				"type": 27
			}
		},
		"type": 17,
		"protocol_version": "2.1.1",
		"sketch_name": "RGBW Light",
		"battery_level": 0
	}
}

It works!!!

After a couple of hard reboots of the Pi running HA the colorpicker appeared on screen.
did not change anything else after the last post.

Thanks for the help though!

1 Like

I hope its ok if I use the same thread: I am trying to use a similar node and its not working (yet) with home assistant. All those messages I have to send back seem to result in an endless cycle of messages beein send back and forth at the moment.

@bram2202 could you tell what code worked for you in the end?

Also I noticed that the code you posted above uses the same child sensor id for all 3 children (RGBW/STATUS/DIMMER). Is this intended? As far as I know you should use different IDs here.

Here is a link to my Git repo and the latest code i used with my arduino.

I ditched the V_RGBW and used V_RGB AND V_PERCENTAGE to controle the RGB and white lights separately.

For my project i used a WS2801 led strip and a warm white led strip.
This way i can use the WS2801 leds for color (no white) and the other leds for the warm white light.

rgb_msg & status_msg & dimmer_msg have the same child ID
light_msg & percentage_msg have the same (but other) child ID

https://github.com/bram2202/HomeAssistant/blob/master/Arduino/RGBW2.ino