NodeRed - call node "property" in node "function"

Hello guys

I wrote some code in the “function” node, but I need data stored in the “property” of the device. I would like to be able to call “property read” and “property write” inside the “function” node.

Is it possible to call the “property read” and “property write” node inside the “function” node?

Something like:
json_device_property = property_read(asset, asset_id, property);

and

payload = json_property;
property_write(asset, asset_id, property, payload);

thanks

Hi,

For that I use the “property read” and “property write” node.

Maybe what you need is to add a function node to change the keys into the running msg and avoid destroying the payload info from a previous node.

For example, after the “property read” node, all the info from this node is into the msg.payload key, so you can add a function node to store msg.payoad as msg.propertyRead (as example), so the next node if have some payload to return, you wont lose the property read and will have available for use later into other “function” node.

Hope this helps.

Hey @George_Santiago

It is not possible to call them directly from the function node, but you can pass a message with your desired values into the property read and write nodes.

Example
Function node:

msg.asset = "device";
msg.asset_id = "device_1";
msg.property = "property_1";

return msg;

By sending that message into the property read node you’d get the value of the property into msg.payload.

Check the help tab in Node-RED for details on each node.
node-red_read_property

Regards.

I’m adopting a similar strategy using function nodes in parallel with property-read, joined at the end with the join node.
As we don’t have an alert handler in Thinger yet, I’m developing one. But the learning curve with NodeRed is steep, compared to being able to write the code in the same notebook (as we do in the function node).

I hope the next release Alerts Manager will be available, it will help a lot in device management.

Thank you for your help.

I used to do this, then learned how to save the payload with another key by a function node, I prefer do this because you may add as much info as you want, using any read node and then saving the returned msg.payload as another key in the same msg, is an easy way to keep the previous payload.

Just need to add a function node and add the following

msg.NEWKEY= msg.payload
return msg

This will allow you to destroy the payload, having it available into msg.NEWKEY, for the following nodes.

You can add newkeys as you need.

Hope this helps.