This documentation is for older software versions (up to 3.1.29). If you have software version 3.1.30 or higher, go to MODERN Home

(Classic) Change node - Setting and triggering variables

With change node, it is possible to save messages that are coming out of the nodes and reuse them.

Use of variable

The context object - stores data inside a single node,

The flow object - stores data for a sing flow tab,

The global object - stores data for the whole logic.

This article will cover knowledge about flow and global objects.

A node used to set the message as a variable is a change node.

It can both, set a flow.variable to msg.payload (1) and
set a msg.payload to flow.variable (2).

(1) To set a variable flow.var_01 as a value of msg.payload:

The value of the variable (var_01) will be overwritten and the value of the original message will be passed on without modification.

For example, if the message with the value “100” will come into a node, it will be saved as a value of a variable.

(2) To change the incoming message into a variable, the “Set” rule has to be used in the other way

Now the output of the change node will be the value which is stored as a variable (var_01).
Every incoming message will be changed into a value of a variable.

Checking the value of variables

The value of the flow is shown in the “context” tab.

[{"id":"406a3ac6.1ce274","type":"change","z":"cbbad29d.a61b88","name":"","rules":[{"t":"set","p":"var_01","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":780,"y":1140,"wires":[["7c2d8de3.4ff474"]]},{"id":"34653ef5.68f36a","type":"inject","z":"cbbad29d.a61b88","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"0","payloadType":"num","x":530,"y":1120,"wires":[["406a3ac6.1ce274"]]},{"id":"7c2d8de3.4ff474","type":"debug","z":"cbbad29d.a61b88","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1030,"y":1140,"wires":[]},{"id":"1860d79d.53c378","type":"inject","z":"cbbad29d.a61b88","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"100","payloadType":"num","x":530,"y":1180,"wires":[["406a3ac6.1ce274"]]}]

Any variable name can be set, the important thing is that the flow creator is aware of what it is used for. Variable name has to be distinguish for a specific usage.

Use cases

HCL

In logic when the presence detection has to trigger a value from the Intensity Scheduler (ES_CCT node).

https://glamox.atlassian.net/l/cp/djTKua8c

Daylight harvesting blocker

Turning ON daylight harvesting at a scheduled time.

[{"id":"b47e24a3.87534","type":"light-scheduler","z":"7cc4cc5b.0ed7e4","settings":"994a1915.7cbd08","events":"[{\"start\":{\"dow\":2,\"mod\":570},\"end\":{\"dow\":2,\"mod\":1020}},{\"start\":{\"dow\":1,\"mod\":570},\"end\":{\"dow\":1,\"mod\":1020}},{\"start\":{\"dow\":3,\"mod\":570},\"end\":{\"dow\":3,\"mod\":1020}},{\"start\":{\"dow\":5,\"mod\":570},\"end\":{\"dow\":5,\"mod\":1020}},{\"start\":{\"dow\":6,\"mod\":570},\"end\":{\"dow\":6,\"mod\":1020}},{\"start\":{\"dow\":0,\"mod\":570},\"end\":{\"dow\":0,\"mod\":1020}},{\"start\":{\"dow\":4,\"mod\":570},\"end\":{\"dow\":4,\"mod\":1020}}]","topic":"","name":"Activate Daylight from 9:30 to 17:00","onPayload":"true","onPayloadType":"bool","offPayload":"false","offPayloadType":"bool","onlyWhenDark":false,"scheduleRndMax":"","sunElevationThreshold":6,"sunShowElevationInStatus":false,"outputfreq":"output.statechange.startup","x":240,"y":280,"wires":[["27d12932.6e5c96"]]},{"id":"79ab4d19.363194","type":"inject","z":"7cc4cc5b.0ed7e4","name":"enable","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":"","topic":"","payload":"true","payloadType":"bool","x":460,"y":240,"wires":[["27d12932.6e5c96"]]},{"id":"151acf62.a6f591","type":"inject","z":"7cc4cc5b.0ed7e4","name":"disable","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":true,"onceDelay":"","topic":"","payload":"false","payloadType":"bool","x":470.1874351501465,"y":317.9999599456787,"wires":[["27d12932.6e5c96"]]},{"id":"27d12932.6e5c96","type":"change","z":"7cc4cc5b.0ed7e4","name":"Daylight Blocker","rules":[{"t":"set","p":"daylight","pt":"global","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":694,"y":276,"wires":[[]]},{"id":"ead5480b.7c0a68","type":"comment","z":"7cc4cc5b.0ed7e4","name":"Daylight Harvesting ","info":"in this node the taget for 70 % and 60% is set in the message payload\n\n\n\n{ \"target\": 270, \"tolerance\": 3 } ","x":190,"y":220,"wires":[]},{"id":"8a54c569.279b9","type":"switch","z":"7cc4cc5b.0ed7e4","name":"Daylight is true","property":"daylight","propertyType":"global","rules":[{"t":"true"}],"checkall":"true","repair":false,"outputs":1,"x":1080,"y":440,"wires":[["92e5b50d.9392f8"]]},{"id":"ed4a081.745f478","type":"vertex action","z":"7cc4cc5b.0ed7e4","name":"Zone 1","typeButton":"directv","bPayload":{"action":"setbrightnesslog","group":null,"param":0,"priority":"254"},"bState":false,"defaultpriority":true,"x":890,"y":440,"wires":[["8a54c569.279b9"]]},{"id":"2ba98ced.071f9c","type":"change","z":"7cc4cc5b.0ed7e4","name":"Send 10% (170)","rules":[{"t":"set","p":"payload","pt":"msg","to":"170","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":660,"y":460,"wires":[["ed4a081.745f478"]]},{"id":"609f5f95.801ef8","type":"switch","z":"7cc4cc5b.0ed7e4","name":"If below 10% (170)","property":"payload","propertyType":"msg","rules":[{"t":"gte","v":"170","vt":"num"},{"t":"lt","v":"170","vt":"num"}],"checkall":"true","repair":false,"outputs":2,"x":670,"y":420,"wires":[["ed4a081.745f478"],["2ba98ced.071f9c"]]},{"id":"8341222d.514958","type":"vertex daylightHarvesting","z":"7cc4cc5b.0ed7e4","name":"Daylight Harvesting","primarygroup":"a33e9e31541f7073db5297e2ca9c0932","target":"300","tolerance":"3","P":"0.3","I":"0.04","D":"0","min":-25,"max":25,"x":430,"y":440,"wires":[["609f5f95.801ef8"]]},{"id":"5402dee5.701d48","type":"dali2devs","z":"7cc4cc5b.0ed7e4","name":"S1 - Light","uid":"CEFF083F00790400","dali2dev":"1","instanceType":4,"dali2t1":"900","dali2t2":"30","mode":"","x":160,"y":440,"wires":[["8341222d.514958"]]},{"id":"8d672d7.177f3d","type":"vertex feedback","z":"7cc4cc5b.0ed7e4","name":"","primarygroup":"70b9813b4cbb3cc545a20a2d6bbebf54","x":180,"y":500,"wires":[["8341222d.514958"]]},{"id":"92e5b50d.9392f8","type":"vertex cluster","z":"7cc4cc5b.0ed7e4","rate":90,"x":1320,"y":440,"wires":[]},{"id":"994a1915.7cbd08","type":"light-scheduler-settings","name":"aalborg","latitude":"57.02515165179153","longitude":"9.9455264189402"}]