Global Var in JSON

Hello,
I would like to replace the injection nodes with a slider. To do this, I created a global variable “Slider”. How can I replace this with the fixed number 50 in JSON?

I wanted to change this:

grafik

to this:

{
"brightness": global.get("Slider"),
"turn": "on"
}

But it doesn´t work

Change from static JSON to "expression" which uses JSONata. Then you can use the $globalContext function. The rest of your JSON can stay the same.

Far easier and cleaner to simply add another row to the inject node IMO

You aren't setting a global context variable solely to get the output of your slider into json format for passing to the Shelly are you?
If so, here is an alternative approach:

image

Thanks for the quick responses! All 3 solutions work. In this use case I really just want to control the Shelly, but I also wanted to know how to assign global variables variably. Thank you very much!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.