Help:Node-RED, turn on light with variables in Data

Hi
may someone can help me to solve following problem:

This is the data field i m sending to the light. {“brightness_pct”:40,“color_temp”:480}
now i created a boolean in ha to have a slider to change the color_temp. I tried several things (with function and also change nodes) but nothing worked for me.

The plan is to have a node state_changed (boolean slider in HA) soon i change this it should change the variable witch i use instead of the static 480.

i don t understand how the variables working in node red.

i tried following:

state_changed: input_number.lichtfarbe_nacht (ha slider)


.
.
function:
image
global.set(“lichtfarbe_nacht”,msg.payload);
return msg;

then call status with data:

{“brightness_pct”:100,“color_temp”:"{{lichtfarbe_nacht}}"}

but i get always following error message
“Call-service API error. Error Message: expected int for dictionary value @ data[‘color_temp’]”

i gone through some other posts but can t find a solution for me.

Many thanks
br
Martin

use “ct” instead.

Hi i tried to set it on {“brightness_pct”:100,“ct”:“{{lichtfarbe_nacht}}”} but this is not working, i believe thist light need color_temp, there is no value set in color_temp

image

Ah ok, I just set up a test ‘Call Service’ node and this worked
image

FYI - Values from 100 to 400 changed my bulb temperature.

image

You want the light to turn on in a certain color_temp as soon as you move the input_number slider, right? This should suffice:

[{"id":"c9e8ebad.f10138","type":"server-state-changed","z":"889a240f.b5b058","name":"State changed","server":"9405c3fe.d0a6c","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"input_number.lichtfarbe_nacht","entityidfiltertype":"exact","outputinitially":false,"state_type":"num","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":true,"for":0,"forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"x":230,"y":200,"wires":[["8a187a39.7bfc68"]]},{"id":"8a187a39.7bfc68","type":"api-call-service","z":"889a240f.b5b058","name":"Licht Flur Büro","server":"9405c3fe.d0a6c","version":1,"debugenabled":false,"service_domain":"light","service":"turn_on","entityId":"light.licht_flur_buro","data":"{\"brightness_pct\": \"100\", \"color_temp\": \"{{payload}}\"}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":430,"y":200,"wires":[[]]},{"id":"9405c3fe.d0a6c","type":"server","name":"Home Assistant","addon":true}]

Hi
in generell i want to set a global variable and use this after in a service call.
i want to have two variables in the service call data (brightness and color_temp.

i did it now in that way:

image

function color_temp:
image

function brightness:
image

after i use it for the call service:

function:
image

call service:

call service data:
image