Help linking a Tuya device to Vera via Node-Red

Part of issue is “Target” try “Status”

Here is cleaner flow you set the topic in the inject, that way you can have multiple feed in the mios out node as it has nosetting except the vera ip.

[{"id":"6cfd304a.b1cf5","type":"inject","z":"8d8a515a.78af18","name":"Get Switch Status","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"30","crontab":"","once":false,"onceDelay":0.1,"topic":"Kids Bedroom:Star-Light:Status","payload":"{\"operation\":\"GET\",\"dps\":\"20\"}","payloadType":"json","x":150,"y":220,"wires":[["6a751d6.f76bee4"]]},{"id":"6a751d6.f76bee4","type":"tuya-smart-device","z":"8d8a515a.78af18","deviceName":"Start Light","deviceId":"bfbfaa09add7bf7f6aegz2","deviceKey":"4583174a2360f033","x":350,"y":220,"wires":[["f703f3ce.003188"]]},{"id":"f703f3ce.003188","type":"change","z":"8d8a515a.78af18","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"[\"20\"]","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":490,"y":320,"wires":[["3686084c.5e8f9"]]},{"id":"3686084c.5e8f9","type":"mios-out","z":"8d8a515a.78af18","name":"Vera Virtual Switch","server":"65346e95.6ecc98","item":"","x":730,"y":320,"wires":[]},{"id":"65346e95.6ecc98","type":"mios-server","z":"","name":"Vera-Plus","host":"","port":"3480"}]

Target works !

If I add a temporary inject


That will turn OFF the virtual switch in Vera and likewise if I add the inject to the msg.payload.1 template node it will turn on the virtual switch.

There is nothing on your modified flow to convert the true or false boolean coming from the Tuya cloud API to a 1 or a 0 that the virtual switch in Vera will understand for its Target variable.

Yes i just realised that, 1 minute
here is the replacement chane node.

[{"id":"f703f3ce.003188","type":"change","z":"8d8a515a.78af18","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"[\"20\"] = true? \"1\" : \"0\"","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":440,"y":320,"wires":[["3686084c.5e8f9","463a9b4d.d5907c"]]}]

AS to Target
I can not get Target to work. Status works for me.

Both should be updated, even if status is enough from a UI point of view.

Doesn’t appear to be working.

Currently the Star Light is turned OFF in the Smart Life mobile app it shows as off.

Currently in Vera my virtual switch is turned ON. So its out of sync as a test.

I then run the inject expecting the virtual switch in Vera to then be turned OFF.

But it remains ON and doesn’t change state.

I have tried Target and Status also.

We are talking on the same lines ? This flow is to monitor the status of the switch ON or OFF / True or False from the Tuya Cloud API. Then it controls the virtual switch in Vera to set it to the correct state.

I am setting 0 in the debug which looks correct as the switch is now off / false.


But the virtual switch in Vera remains ON when it should be OFF.

Yes does not like [“20”]
try this change node

[{"id":"f703f3ce.003188","type":"change","z":"8d8a515a.78af18","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"`20` = false ? \"0\" : \"1\"","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":440,"y":320,"wires":[["3686084c.5e8f9","463a9b4d.d5907c"]]}]

On my system
Lounge:Lounge 1:Target set variable but does not turn on light.
Lounge:Lounge 1:Status will set variable and turns on light.

It may be different for a virtual http switch.

Nope still the same the virtual switch in Vera is not operated or changed to what ever the status of the Tuya devices switch is currently? coming from their cloud API.

Check the mios ip
If that is correct post flow and debug from tuya node please.

That is correct as I said if I manually inject further down the chain the virtual switch in Vera does change ON of OFF.

But its not changing for some reason when trying to get the dps 20 status.

Now I can see a 1 in debug if I turn on the light via the Smart Life app. And I see a 0 when I turn it off so that appears to be correct. But seems the message payload being sent to the Vera virtual switch isn’t quite right.

Whats the topic in the inject node?

This is a similar setup for the eWeLink flow. The even listener changes the virtual switch in Vera depending on the ON or OFF status of the device in the eWeLink cloud.

We had to use a template node on that one.

On your inject node its

Kids Bedroom:Star-Light:Status

and I’ve tried

Kids Bedroom:Star-Light:Target

On the temporary inject node I used to test the virtual switch can be turned on and off OK by node-red which it can, that inject node had no topic.

And a debug after the change node, as i have it working flawlessly. Maybe the tuya is removing the topic.

Its working now !

I removed the topic from the inject node and instead I added “Kids Bedroom:Star-Light:Status” in to the Item field on the MIOS OUT node.

Now when I turn the light on or off via the Smart Life app the virtual switch in Vera also changes to on or off.

Add the topic in the change node as that keeps the mios node free to be used dynamically by other flows.

In fact you could edit the ewelink flow and feed it in to the same out node.

OK done that and it works also.

Add an rbe node before change node then only if value changes from false to true and ture to false will the mios be activated.

[{"id":"c4d34238.141fd8","type":"rbe","z":"8d8a515a.78af18","name":"","func":"rbe","gap":"","start":"","inout":"out","property":"","x":270,"y":380,"wires":[["f703f3ce.003188"]]},{"id":"f703f3ce.003188","type":"change","z":"8d8a515a.78af18","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"`20` = false ? \"0\" : \"1\"","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":480,"y":380,"wires":[["463a9b4d.d5907c","3686084c.5e8f9"]]}]

This is very note worthy !

I don’t even need an Interval set in the inject node and it still works.

When using either “Kids Bedroom:Star-Light:Status” or “Kids Bedroom:Star-Light:Target” as the topic, I can remove completely the 15 second Interval from the inject node.

And it still works when I use the Smart Life app to turn ON or OFF the light the virtual switch is also changed correctly and its fast the virtual switch updates within a few seconds.

I wasn’t expecting that to be the case and thought the inject node would have to be set to “poll” by using an interval.

I have not tried your last edit yet either with a rbe node.

Best Home Automation shopping experience. Shop at getvera!

© 2021 Ezlo Innovation, All Rights Reserved. Terms of Use | Privacy Policy | Forum Rules