Newbie fails with json formula

Hello, i've just started with nodered and set up the first routines, flows etc.
But i have some problems with controlling my lamps.

I use IKEAs Tradfri lamps, which want their brightness value as JSON like {"brightness":255}
in the UI i have a slide controller which outputs a value from 0 to 255 I thought also of using a slider from 0 to 100 and later multiplying with 2.55 to achieve the correct value but unsure how to round as the lamp does not understand values with values after a point (sorry i dont know the english term)

Can someone explain to me how I put a formula behind it, which then converts the incoming numerical value into a JSON object that I can send to the lamp?

BR

Several ways to do it - this is one way without having to write code using the template node

[{"id":"d7fb13a8.b1718","type":"inject","z":"178669c6.ca0c76","name":"","topic":"","payload":"123","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":974,"y":220,"wires":[["dce96616.044898"]]},{"id":"dce96616.044898","type":"template","z":"178669c6.ca0c76","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"{\"brightness\": {{payload}} }","output":"json","x":1132,"y":220,"wires":[["6794f9ec.115fb8"]]},{"id":"6794f9ec.115fb8","type":"debug","z":"178669c6.ca0c76","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":1360,"y":220,"wires":[]},{"id":"4df70225.813d1c","type":"inject","z":"178669c6.ca0c76","name":"","topic":"","payload":"255","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":974,"y":264,"wires":[["dce96616.044898"]]}]
1 Like

Thank you very much @cymplecy

Added it and it works just fine. thanks again!