.. so I'm after a way of converting a hex string cheerlight colour "#xxyyzz" to an array [xx2,yy2,zz2] where xx2 etc are decimal versions of xx etc
This is for some Wiz RGB lights
Preferably using core or contrib nodes of course ![]()
.. so I'm after a way of converting a hex string cheerlight colour "#xxyyzz" to an array [xx2,yy2,zz2] where xx2 etc are decimal versions of xx etc
This is for some Wiz RGB lights
Preferably using core or contrib nodes of course ![]()
Hi @cymplecy
Using my basic understanding of parseInt (which accepts hex values)
const hex = msg.payload.replace('#', '');
msg.payload = [
parseInt(hex.substring(0, 2), 16),
parseInt(hex.substring(2, 4), 16),
parseInt(hex.substring(4, 6), 16)
];
return msg;
there might be a way in the change node using j; - but that's above my pay grade.. perhaps @E1cid ![]()
Side Note: does this mean we will see an outdoor button this year ![]()
Ugly but
$match( $substringAfter($$.payload,"#"),
/[0-9a-fA-F]{2}/).
$number("0x" & $.match)
or simple and cleaner
[
$number("0x" & $substring($$.payload,1,2)),
$number("0x" & $substring($$.payload,3,2)),
$number("0x" & $substring($$.payload,5,2))
]
Button box should be in action again (but not found where I put it yet!) ![]()