node-red-contrib-tuya-local icon indicating copy to clipboard operation
node-red-contrib-tuya-local copied to clipboard

Setting multiple DPS values

Open christopherpm opened this issue 4 years ago • 2 comments

I'm trying to use node-red-contrib-tuya-local to turn on an RGBIC striplight and set some of it's values.

I have an inject with a payload message of on. The output of this inject goes to the input of a function, and the code for this function reads:-

if (msg.payload === "on")
msg.payload =
{
    "set": true,
    "dps": 20
}

return msg;

The output of this function then goes to the input of the tuya-local device.

The above does work to turn on the striplight.

How do I set more DPS values at the same time in the same payload, e.g. 20=true, 25="03e832020", 104=10 ?

I tried the following, but even formatting like this, the light doesn't even turn on:-

if (msg.payload === "on")
msg.payload =
{
    dps: 
    {
        "20": true,
        "104": 11
    }
};

return msg;

christopherpm avatar Feb 10 '21 20:02 christopherpm

I had to go through the code I couldn’t remember if this was allowed. In the payload property you need a key “multiple” set to true. Try that.

subzero79 avatar Feb 11 '21 20:02 subzero79

The syntax is msg.payload = { “multiple”: true, “data”: { “dps#”: dpsvalue, “dps2#”: dps2value … } }

txwireless avatar Jan 16 '24 00:01 txwireless