I am setting up controls for Osram bulb and setting reusable flow variables in a system values node i.e. for my Osram dimmer bulb:
flow.set("OsramBulbDimmer", {"cluster_id":"0x0008", "endpoint_id": "3", "command_id": "0x00", "parent_command": "zcl level-control", });
In the function node I am trying use an entry like below where the dimmer params are appended to the flow variable in the payload (dimmerlevel is a numeric value already set), but I get get formatting errors every which way I try to spin it.
msg.payload = {flow.get("OsramBulbDimmer") , "params":{level: dimmerlevel, "transition time": 10}};
This way kind of works, but it creates a new object in the payload for the variable name "bulbval" and the bulb rejects the command.
var bulbval = flow.get("OsramBulbDimmer");
msg.payload = {bulbval, "params": {level: dimmerlevel,"transition time": 10}};
For comparison, if I set the entire payload in the function node like this then it works:
msg.payload = {
"cluster_id":"0x0008",
"endpoint_id": "3",
"command_id": "0x00",
"parent_command": "zcl level-control",
"params":{level: dimmerlevel,"transition time": 10}},
Hi Damians - thx for the reply. That will probably work as its very close to my working scenario where all the commands are individually specified in the function node. What I'm trying to do is get away from doing that and make those common commands flow level variable so I can re-use in other nodes. In my mind thats a neater solution.