Page 1 of 1
How to set a color?
Posted: 25 Oct 2016 17:20
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?
Re: How to set a color?
Posted: 26 Oct 2016 08:19
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
Re: How to set a color?
Posted: 26 Oct 2016 14:42
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.