Hi. I'm moving my first steps in node-red, and I'm facing a lot of problems since the template flow that I need to use for my needs contains a lot of stuff that I still don't understand.
My first need is to create some objects that contains each one the values of the object "dps" that I have retrieved within a payload:
You can create an object with key/value like this in a function node...
msg.payload = {
key: "value"
}
so if you want the value of dps in a key/val you would...
msg.payload = {
dps: msg.payload.dps["1"]
}
There’s a great page in the docs that will explain how to use the debug panel to find the right path to any data item.
Pay particular attention to the part about the buttons that appear under your mouse pointer when you over hover a debug message property in the sidebar.
Of course @Colin: I need to control locally a tuya appliance that I can't integrate in home Assistant with the LocalTuya custom component.
With the node-red-contrib-tuya-local node I can control that appliance, and my main idea is to use MQTT as a bridge between Node-Red and HA, and to create a climate device based on MQTT.
The node's payload {"devId":"228780332cf432062e35","dps":{"1":false,"2":15,"3":24,"7":false,"10":"0","11":0,"101":"0","102":false}} showed me the dps keys/values that I should send to MQTT, for example the payload.dps["7"] routed to something like "/tuya/bimar_local/swing/" (that is a nice example, since I can't control that function with HA), and so on.
Sorry I've replied before reading your post.
Is it possible to set not only the key 7 as msg.payload but also convert its value from boolean to "on" and "off"?
I'm trying to obtain that with the expression of my previous reply but without success. I imagine that it happens because I should write in JSonata?