[RELEASE] Tuya Zigbee Valve driver (w/ healthStatus)

Although the different Tuya branded Zigbee valves may look the same, they are produced by different manufacturers and have different Zigbee commands implemented.
Most of the Tuya valves should work in HE stright away, using the inbuilt Sinope Water Valve driver.

In the cases when Sinope Water Valve driver does not work for your model, you can try this driver that is intended to provide support for several different Tuya modles.

The recommended installation method is to use the community Hubitat Package Manager (HPM) app. Search for "Tuya Zigbee Valve" or by tag 'Zigbee'.
The driver can be also installed manually from this link : https://raw.githubusercontent.com/kkossev/Hubitat/development/Drivers/Tuya%20Zigbee%20Valve/Tuya%20Zigbee%20Valve.groovy

Supported models

Device Links
Tuya ZigBee 3.0 Smart Gas Water Valve Controller image AliExpress: (link)
AliExpress: (link)

Review: (link)
Review: (link)
Tuya Water Gas Shut Off Valve image Amazon.de: (link)
SASWELL Irrigation Timer
image
Saswell: link
Amazon: link
Domadoo .fr : link
Domotique .fr : link

| ZIGBEE Sprinkler / Water Irrigation Valve
image | Amazon : (link) |


Compatibility

  • Tuya specific cluster 0xEF00 valves
    • model:"TS0601", manufacturer:"_TZE200_vrjkcam9"
  • Valves that need Tuya specific initialization
    • model:"TS0001", manufacturer:"_TZ3000_iedbgyxt"
  • Standard Zigbee 3.0 (ZHA 1.2) valves
    • various models

Features

  • Standard "Valve" capability
  • Debug/Info logging
  • Power-On Behaviour preference setting
  • healthStatus

3 Likes

REVISIONS HISTORY:

  • ver. 1.0.0 2022-04-21 - inital version
  • ver. 1.0.1 2022-04-23 - added Refresh command; [overwrite: true] explicit option for runIn calls; capability PowerSource
  • ver. 1.0.2 2022-08-14 - added _TZE200_sh1btabb Water Irrigation Valve (On/Off only); fingerprint inClusters correction; battery capability; open/close commands changes
  • ver. 1.0.3 2022-08-19 - decreased delay between Tuya commands to 200 milliseconds; irrigation valve open/close commands are sent 2 times; digital/physical timer changed to 3 seconds;
  • ver. 1.0.4 2022-11-28 - added Power-On Behaviour preference setting
  • ver. 1.0.5 2023-01-21 - added _TZE200_81isopgh (SASWELL) battery, measuredValue, automatic timer state, timeLeft, lastValveOpenDuration; added _TZE200_2wg5qrjy _TZE200_htnnfasr (LIDL);
  • ver. 1.1.0 2023-01-29 kkossev - added healthStatus

The development branch version that contains the latest additions and bug fixes can be manually downloaded from here: https://raw.githubusercontent.com/kkossev/Hubitat/development/Drivers/Tuya%20Zigbee%20Valve/Tuya%20Zigbee%20Valve.groovy

This seems like exactly what I need and looks great, but it isn't working for me. My manufacturer is listed as "_TZE200_sh1btabb", is this the problem?

This Tuya manufacturer is not in the list of the known devices (yet).

Make sure the Debug option is turned on, then power the valve off, wait 10-15 seconds and power it on again.

Switch the valve for on/off from the device button.

Then post the debug logs (you can do this in. a PM )

P.S.
Have you tried the built in Sinope driver?
Also, when this Tuya driver is selected, pair the valve for a second time. Some Tuya and Aqara devices do not pair successfully to the hub from the first try,

I just searched for information about this device, and it is something very different than the simple water/gas shutter valve... It's a much more complex smart irrigation controller. Seems like the water flow can be regulated in 5% steps, not just fully opened/fully closed like the shutter valves.

Such a controller will require a custom driver to handle the specific Tuya commands for it, there is not a known driver for Hubitat yet.

Ok. I have a development background, can you help me get started? It's unclear to me how one determines what the commands are from interrogating the device.

Alternatively, is there a similar, battery powered hose connected device which you have a driver for already?

Many of Tuya platform devices do not follow the Zigbee Cluster Library specifications, so the commands for each particular device are usually reverse-engineered by sniffing the traffic when connected to Tuya proprietary Zigbee coordinator. Often this work is already done by other home automation communities :), so it becomes a matter of finding the information on Github. Searching Github for _TZE200_sh1btabb" shows that this device is already supported in ZHA and Zigbee2MQTT, so the information on the commands ('data points' in Tuya terminology) is already there.

It shouldn't be so hard to add support for this device in Hubitat, the only problem is the time .. ;(
If you are sure that you want to dive into writing Zigbee drivers for Hubitat, I will surely help you to get started. The first step is to understand the debug logs that most of the HE drivers provide, so my proposal was to start from here.

I also found those pages in GitHub last night. I think I'm missing some sort of primer on zigbee drivers. I searched around a bit and mostly found official protocol documentation which would be laborious to consume. Can you recommend a good 101 guide?

1 Like

Hubitat developer documentation is here: Developer Documentation - Hubitat Documentation

You could start from the sample drivers here : HubitatPublic/examples/drivers at master · hubitat/HubitatPublic · GitHub An good Zigbee Hubitat driver code is : https://github.com/hubitat/HubitatPublic/blob/master/examples/drivers/advancedZigbeeCTbulb.groovy

For me, a very useful source of information was also the old SmartThings documentation: Device Handlers — SmartThings Developer Documentation
Not everything in this SmartThings document applies to Hubitat drivers, but the principles are the same. Also this: https://buildmedia.readthedocs.org/media/pdf/smartthings/latest/smartthings.pdf

3 Likes

This has unfortunately not lead me down the path I had hoped. It turns out the ZHA support is false, their work didn't go anywhere either.

If I'm understanding correctly, the mqtt work does not contain the zigbee commands themselves, rather the instructions to the Tuya hub to send the zigbee commands. Is that correct?

There is no way to communicate directly to Tuya zigbee hub, These communicate only to Tuya cloud. Tuya cloud provides API for integration to other systems - it is used in HE by this excellent project : [BETA] Tuya Cloud Driver (Limited device support)
This is one possible way to bring Tuya devices to HE, that do not have a Zigbee driver yet (or the devices use WiFi or BT communication to Tuya hub).

An MQTT broker does not directly talk to Tuya devices or Tuya Zigbee hub, In Home Assistant, the Zigbee2MQTT add-on communicates to a lot of Zigbee devices from one side and to HA MQTT broker on the other side.

Ok, that's interesting. I think the outcome is the same though; the information I need to write a zigbee driver is not contained within the mqtt code we both found on GitHub, meaning the only way for me to get it is to buy a Tuya hub, and a zigbee dongle and sniff the traffic. Correct?

Having a Tuya Zigbee hub and sniffing the traffic is very useful, but not absolutely necessary. I have it, but I use it relatively rarely, I call this approach 'the heavy artillery ' :slight_smile:

Usually, collaborators from Home Assistant or deConz, or other HA communities have already walked this way, so the information needed to add a particular device is already available on GitHub. As of today, searching GitHub for '_TZE200_sh1btabb' finds 3 issues (the request, discussions implementation, and test results of the same device in both ZHA and Zigbee2MQTT) and 1 'code' ( Zigbee2MQTT definitions for this Water irrigation valve). In our case we are lucky as almost all of the information can be found in this single giex.js file. Here we have all the Tuya 'data points' - parameters that are reported from the device (fzLocal) and commands / parameters that can be sent to the device (tzLocal ). We still have to guess what is the meaning of 'mode' vs 'state' vs 'irrigation_target', etc... In this case, I have not spent time reading more about this device, so most of parameters and commands are not very clear to me.

Next step is to start adding the new device commands and parameters to a new or better find an existing HE driver that is most close to the new device functions. This driver can be a good starting point, although this irrigation valve is much more complex that the simple on/off valve. But often not all of the particular Tuya device parameters needs to be implemented in Hubitat. Probably all these 'irrigation start', 'irrigation end', irrigation duration parameters (having a strange data type 'GMT+8' - this is the China central time zone :slight_smile: ) are not needed in HE, because the operation of the valve will be controlled by Hubitat.

If you want to continue with writing the driver, let me know.

I absolutely do and this is super helpful, I think my mental model is almost complete enough to begin. One thing that's not clear just yet, wears the relationship between clusters (seemingly simple memory addresses or similar) and the human readable datapoints etc named in the above mentioned file?

More to the point, I'm under the impression that I need to send some specific magic numbers to the device and that those datapoints are convenience names. Seems like maybe that's where my disconnect is.

I would like to know if anyone has seen or worked with these. One of the three reviews says it doesn't work with Hubitat but I think it is pretty new and maybe nobody has it yet to sniff it out. If I were to purchase one, what would someone need to get it to work with a driver? It mentions it is a Tuya chipset and, right now, would require a Tuya hub. I would happily be the test rat if it means getting away from the Orbit setup I have now.

https://www.amazon.com/ZIGBEE-Sprinkler-Separate-Watering-Schedules/dp/B0B1JN6KZX/ref=asc_df_B0B1JN6KZX/?tag=hyprod-20&linkCode=df0&hvadid=598282648021&hvpos=&hvnetw=g&hvrand=15428936581910857117&hvpone=&hvptwo=&hvqmt=&hvdev=m&hvdvcmdl=&hvlocint=&hvlocphy=9033584&hvtargid=pla-1682274373812&psc=1

Thanks!

1 Like

In the development branch ver. 1.0.2 (the link is in the second post) I have added basic On/Off control for the new Tuya Water Irrigation Valve. I do not have this device and am unsure whether it is only one model/manufacturer. If someone has this or a similar device please make some tests. There is no known way to automatically recognize whether the device is a simple valve or a more sophisticated water irrigation valve, so for each new manufacturer the new fingerprint must be added into this driver. Currently, _TZE200_sh1btabb is recognized as an irrigation valve.

This is a basic On/Off valve control only. There are other advanced features like irrigation timer start/end times, irrigation duration, etc.. which functionality is not clear to me. If someone has this device and can explain the meaning of these parameters and how these can be used in HE, please let me know.

@user1523

Great! I purchsed it and should be here tomorrow. All I really care about is on/off really but my needs are probably far different than others. 5-10 second delay with Orbit is just too much for me to handle anymore for my situation.

When you have it, please send me the debug logs from the first pairing in a PM.
What is your use case, are you planning to use it for water irrigation (limited time on)?
My main doubt is whether this device can be switched on permanently or not.. It's a battery-powered device, so I have a doubt that these complex timers should be used, but we will understand after the tests...

Download the Hubitat app