Recently I wanted to control Tuya-based devices from the GX. Most of the smart timers, plugs, isolators etc that we get locally all seem to use Tuya.
I thought, for those interested I would document my experience and how to go about it.
My use case was to control a geyser, I wanted to use all the free battery capacity in the morning but not hit the ESS limit.
My plan was to create a control logic that monitors the geyser state and battery SOC and turns the geyser on/off as needed until it is at temp.
First step is getting the local access key for each device. This requires moving the device from any third party tuya apps onto the default Tuya smart life app, which is required to access the API.
Follow this video for how to get the local key:
https://www.youtube.com/watch?v=N2EI96Rw9-0
Controlling the device via the cloud was too slow, instead managing them over the LAN is much more reliable.
For this you need the device IP of each, you need to set this to be static on the device or via your home router using reserved DHCP.
At this point you can load node-red-contrib-tuya-smart-device on the cerbo and use the tuya smart device node to connect using the local IP and local key of the device.
My flow is basic it uses the dps register 1 of tuya to turn the device on and off and tracks power consumptions from register 23.
You can query what your device supports via the tuya API on their dev portal.
For my use case, I turn the device on via a normal timer on the app and have a smart scene set that tracks when power drops below 100W (indicating it is heated) and then it turns the geyser off. So no matter how it is activated it will run as long as required to fully heat, then stop.
My flow tracks if the geyser turned itself off, or if it was stopped due to SOC minima, in the latter case, it will keep heating the geyser once the SOC is 4% above the min ESS value (this could be done smarter and linked to the ESS node) and is turned off at 2% above ESS min SOC.
It is a really useful way to control devices via the Cerbo, optimise use and avoid unnecessary grid usage.
The same method can be used for activating pumps, turning on light bulbs (or setting their colour). Next project is to make some house lighting LED's pulse in red on grid loss.