Hi,
my IKEA Dimmer returns brightness values live 0…100…255 but the ha-yeelight service requires brightness values like 0…50…100, how to transform them in node red?
Hi,
my IKEA Dimmer returns brightness values live 0…100…255 but the ha-yeelight service requires brightness values like 0…50…100, how to transform them in node red?
Hi, you can use a function node to convert the value:
msg.payload = Math.round(msg.payload * 100 / 255)
return msg;
Here is a sample flow:
[{"id":"4b73901b.e17ae","type":"inject","z":"17c6db5.4c69d25","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"150","payloadType":"num","x":140,"y":160,"wires":[["356113d8.9951c4"]]},{"id":"356113d8.9951c4","type":"function","z":"17c6db5.4c69d25","name":"","func":"msg.payload = Math.round(msg.payload * 100 / 255)\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":300,"y":160,"wires":[["de7953e5.4d7d8"]]},{"id":"de7953e5.4d7d8","type":"debug","z":"17c6db5.4c69d25","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":470,"y":160,"wires":[]}]
in NR there is a node performing this operation. it’s called Range