Help with `change` node and `global` values

Folks, I'm stuck on how to parse/handle variables in the change node.

Scenario:
global variable: Shutdown_temperature set to 75 (number)

I can easily get that value in the change node.

Set msg.payload to global.Shutdown_temperature.

Easy.

But what if I want Shutdown_temperature - 10?

Adding (or: appending) -10 to the text doesn't work.
Or at time of posting it didn't seem to.

How would I do it without another node? Can it be done?

Do you mean global.Shutdown_temperature - 10 as variable name ? that is not a valid variable name.
Or do you mean you want to calculate global.Shutdown_temperature-10 ? JSONata can do that.

(Yeah, ok my bad.)

I want to get the latter.

global.Shutdown_temperature - 10.

Could you please show me how?

In the change node, set msg.payload to:
JSONata:$globalContext("Shutdown_temperature")-10

This assumes that Shutdown_temperature is a number.

Thanks.

Putting aside I (again) goofed with the name. Quickly and easily fixed.

For another reason, it doesn't seem to want to play the game.

This is the flow:

[{"id":"3e63b997.6fd786","type":"inject","z":"10dda891.0445cf","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":210,"y":1550,"wires":[["cb8cc631.9ff27"]]},{"id":"3b668264.063ba6","type":"debug","z":"10dda891.0445cf","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":640,"y":1550,"wires":[]},{"id":"cb8cc631.9ff27","type":"change","z":"10dda891.0445cf","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"$globalContext(\"shutdown_temperature\")-10","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":390,"y":1550,"wires":[["3b668264.063ba6"]]}]

This is the screen I see:

Screenshot%20from%202019-10-27%2023-55-49

Pressing the inject node..... Nothing comes out.

I'm an idiot!

I had the field set to {} instead of J: Too used to using the {} option.

1 Like