How to set a color?

Discussions about Z-Way software and Z-Wave technology in general
Post Reply
injecteer
Posts: 13
Joined: 29 Sep 2016 16:28

How to set a color?

Post by injecteer »

I have a switchRGBW ligtht bulb and I'm trying to change it's color like so:

Code: Select all

var dev = controller.devices.get( 'ZWayVDev_zway_' + k );
dev.set( 'metrics:color', {"r":11,"g":22,"b":33} );
but it doesn't work. I mean, the "metrics:color" value gets changed, but not bulb's color.

What am I missing?
pah111kg
Posts: 25
Joined: 02 Sep 2016 18:49

Re: How to set a color?

Post by pah111kg »

Hi,

That should work:

Code: Select all

var dev = controller.devices.get( 'ZWayVDev_zway_' + k );
dev.performCommand( 'exact', { red: 11, green: 22, blue: 33 } );
Note that the names of metrics properties are r, g, b but in command you have to name the parameters red, green, blue.

Regards,
Patrick
injecteer
Posts: 13
Joined: 29 Sep 2016 16:28

Re: How to set a color?

Post by injecteer »

Thanks, Patrick, your code works perfectly.

There is some inconsistency in the API though (ver. 11.04.2016 v2.2.2).

I tried the performCommand() before:

Code: Select all

dev.performCommand( 'exact', {"r":123,"b":255,"g":41} );
but was scared off with the not-a-number error:
[2016-10-26 13:38:26.379] [core] --- ZWayVDev_zway_9-0-51-rgb performCommand processing: {"0":"exact","1":{"r":123,"b":255,"g":41}}
[2016-10-26 13:38:26.382] [core] Notification: error (module): Error during perform command execution: Error: Element is not a number


The json { red: 11, green: 22, blue: 33 } is not a number, but works fine.
Post Reply