Tis nearly season to be jolly

.. 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 :slight_smile:

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 :smiley:

Side Note: does this mean we will see an outdoor button this year :wink:

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))
]

Lovely thanks :slight_smile:

Button box should be in action again (but not found where I put it yet!) :slight_smile: