"Tuya Smart WiFi" 6 Zone Irrigation Controller

Thought I’d document a minor success - hope it helps someone else.

I purchased a “Tuya Smart WiFi 6 Zone Irrigation System”. They are available in 6 & 8 zone versions including from aliexpress https://www.aliexpress.com/item/1005001853592539.html.

I bought this rather than going DIY since it comes with a reasonable 24v AC power supply to power the common 24vac water solenoids and has it’s own internal step down supply for the MCUs.

After some difficulty I’ve managed to flash it with Esphome and have it working well with Home Assistant.

Wifi is provided by a TYWE3S with an ESP8266EX onboard. Button input and water solenoid switching is done by a separate MCU (STA lqfp44).

I wasn’t able to get TUYA-CONVERT to work, but the firmware may have been updated as I actually bought this 2nd hand off ebay.

The PCB provides pin headers for the ESP and MCU to simplify flashing (excluding GPIO0). I just pushed male dupont pins in to flash.

I had a trouble flashing. It may be the poor quality 3.3v power supply on my USB-TTL. I also suspect that the STA MCU interrupts the flashing process since the same pins are used. By building a minimal stub esphome firmware (small), powering the TYWE3S from the supplied 24vac, holding GPIO0 to ground, and holding the STA MCU reset pin to ground while flashing I eventually had success.
Subsequent OTA flashing is then flawless.

ESPHOME.yaml

substitutions:
  device_verbose_name: Front Garden Irrigation
  device_id: esphome_irrigation_front
  device_icon: "mdi:sprinkler"
  log_level: "VERBOSE"

packages:
  wifi: !include wifi.yaml

esphome:
  name: "${device_id}"
  platform: ESP8266
  board: esp8285

# Enable logging
logger:
  level: ${log_level}
# Make sure logging is not using the serial port
  baud_rate: 0

# Enable Home Assistant API
api:
  password: !secret api_password

ota:
  password: !secret ota_password

time:
  - platform: homeassistant
    id: homeassistant_time

sensor:
  - platform: wifi_signal
    name: "WiFi signal ${device_verbose_name}"
    update_interval: 60s
   
  - platform: uptime
    name: "Uptime ${device_verbose_name}"
   
text_sensor:
  - platform: version
    name: "Version ${device_verbose_name}"

status_led:
  pin:
    number: GPIO0
    inverted: True

uart:
  baud_rate: 9600
  tx_pin: GPIO1
  rx_pin: GPIO3

# Register the Tuya MCU connection
tuya:

switch:
  - platform: "tuya"
    name: "Zone 1"
    icon: ${device_icon}
    switch_datapoint: 101
  - platform: "tuya"
    name: "Zone 2"
    icon: ${device_icon}
    switch_datapoint: 102
  - platform: "tuya"
    name: "Zone 3"
    icon: ${device_icon}
    switch_datapoint: 103
  - platform: "tuya"
    name: "Zone 4"
    icon: ${device_icon}
    switch_datapoint: 104
  - platform: "tuya"
    name: "Zone 5"
    icon: ${device_icon}
    switch_datapoint: 105
  - platform: "tuya"
    name: "Zone 6"
    icon: ${device_icon}
    switch_datapoint: 106

Before flashing I did try the std Tuya integration.

This device presented with a single switch that turned all irrigation zones on or off, so it wasn’t very useful.

Hi @seanw18, thank you for this great post, was struggling to find anything related to this component.

By flashing you lose all the original capabilities, right? Things like controlling the device using tuya or even setting up the schedules locally on the device?

1 Like

You do lose these capabilities through the Tuya app, but you can provide the same functionality through the esphome itself in various ways if you need it.

The problems with Tuya for me were:

  • all the normal arguments against cloud based services
  • The Tuya app only exposes a single switch for all irrigation zones together in home assistant
  • I’m wanting to use this through the Smart Irrigation integration to get weather based water “dosing”. (https://github.com/jeroenterheerdt/HAsmartirrigation)

You can backup the original firmware (which I did), which apparently allows you to revert. I’m not experienced with this though.

Hello again @seanw18! While attempting to flash I’m getting the error: “ESP Chip Auto-Detection failed: Failed to connect to the Expressif device”. Did you ever get this and how did you fix it?

I’m assuming that it’s because the chip isn’t in Boot mode?

How did you do this? “STA MCU reset pin to ground”

@seanw18 Would really appreciate your input! :smiley:

Have only just seen this sorry.
To “STA MCU reset pin to ground” I just used a grounded dupont cable onto the reset pin.

Has been a while, but I looked at it again:
If you look at figure 3 in this https://www.st.com/resource/en/datasheet/st72321bk6.pdf
It shows the reset pin in relation to the corner “dot”.

1 Like

Hi so sorry to come late to the game on this one. This is exactly what I am trying to do as well. Bought these devices and was trying to integrate into HA as well, but little luck.
Thanks for the write up, and Im going to give this a go.

A*** writeup.

Good News… its worked !!!
Did this to a 8 channel controller. Ended up soldering the wires directly to the ESP chip thou. only needed to ground the ESP to enable the upload.

As a bonus, all the LEDS also still work. All uploaded via ESPHome on Home assistant. Created a default config first, uploaded that, then once that was done, I then updated wirelessly.

Thanks

1 Like

Really happy to hear this has been useful to someone else.
Great work!

I have mine working sucessfully with HASmartIrrigation reliabily for more than a year now.

I ended up using an input to set the runtime for a zone. If connectivity is lost between Home assistant and the device after a zone has been turned on, it’ll still turns off at the desired time. I’m not sure this has ever been a real problem but the controller is at the limits of my wifi range.

1 Like

Can you help which leg needs to zero. And is TX on moko to RX on serial adapter or is it TX to TX, or is there a photo of how in connected cables to serial adapter (to code it).

min is 8 channel

Hi Thanks for replying. I was so happy as it was also my first reflash.
However, I have a issue which I have only just noticed. I can turn on the switch manually without issues and via the automation, but it only stays on for 10 minutes exactly.

Looking at the logs, I cannot see why. Did you see this issue at all?

Hi killerrene

I flashed this so long ago that I can’t be absolutely sure and I only have the photos above.
However I’m pretty sure I will have used TX->RX and RX->TX between serial adapter and the board.

I think I needed to hold GPIO0 (see this) to ground to enter flash mode on the ESP. This was very problematic for me and I’m not sure whether this was because my cheap serial flasher was dodgy. At the time I thought the other MCU on the board was interrupting the flashing process (since the same pins are used). It looks like BEAVERTEETH1978 didn’t need to do this.

I do suggest you build the smallest firmware you can so the flashing process is short and perhaps solder to the board as BEAVERTEETH1978 suggests.

Once the flash works and your device connects to your network you can OTA flash the desired config.

Ha! Interesting BEAVERTEETH1978 - I don’t think I’ve ever run my zones for that long! I need to be pretty water wise.

I’ve just tested with a 16 min runtime and it looks like the TUYA MCU itself switches the zone off a few seconds after 10 minutes. Here’s the key bit of my logs:

[11:26:23][V][sensor:074]: 'Uptime Front Garden Irrigation': Received new state 805013.187500
[11:26:23][D][sensor:124]: 'Uptime Front Garden Irrigation': Sending state 223.61478 hours with 3 decimals of accuracy
[11:26:26][V][sensor:074]: 'WiFi signal Front Garden Irrigation': Received new state -71.000000
[11:26:26][D][sensor:124]: 'WiFi signal Front Garden Irrigation': Sending state -71.00000 dBm with 0 decimals of accuracy
[11:26:30][V][tuya:108]: Received Tuya: CMD=0x07 VERSION=3 DATA=[68.01.00.01.00 (5)] INIT_STATE=5
[11:26:30][D][tuya:255]: Datapoint 104 update to OFF
[11:26:30][V][tuya.switch:011]: MCU reported switch 104 is: OFF
[11:26:30][D][switch:037]: 'Zone 4': Sending state OFF

I also don’t think I’ve ever noticed that the Tuya MCU is querying the local time every 15 seconds, I was getting this warning:

[11:25:52][W][tuya:216]: LOCAL_TIME_QUERY is not handled because time is not configured

but after adding some extra config :

time:
  - platform: homeassistant
    id: homeassistant_time

# Register the Tuya MCU connection
tuya:
  time_id: homeassistant_time

ESPhome then sends the time to the MCU, (but doesn’t fix the issue)

[11:58:00][V][tuya:141]: MCU Heartbeat (0x01)
[11:58:03][V][tuya:113]: Received Tuya: CMD=0x1C VERSION=3 DATA=[] INIT_STATE=5
[11:58:03][D][tuya:457]: Sending local time

So, perhaps there is functionality in the Tuya MCU that hasn’t been detected/explored here, (maybe a zone runtime parameter on the turn-on command that defaults to 10 minutes if it’s not supplied)?

You could try reading this and/or experimenting to see if you can work that out.

A good place to start is what does your device report in the logs when the Tuya MCU is established? My 6 zone device reports this:

[11:47:38][C][tuya:029]: Tuya:
[11:47:38][C][tuya:044]:   Datapoint 101: switch (value: OFF)
[11:47:38][C][tuya:044]:   Datapoint 102: switch (value: OFF)
[11:47:38][C][tuya:044]:   Datapoint 103: switch (value: OFF)
[11:47:38][C][tuya:044]:   Datapoint 104: switch (value: OFF)
[11:47:38][C][tuya:044]:   Datapoint 105: switch (value: OFF)
[11:47:38][C][tuya:044]:   Datapoint 106: switch (value: OFF)
[11:47:38][C][tuya:042]:   Datapoint 107: raw (value: FF)
[11:47:38][C][tuya:050]:   Datapoint 108: enum (value: 0)
[11:47:38][C][tuya:044]:   Datapoint 109: switch (value: OFF)

Maybe these extra datapoints 107-109 are worth investigating?

  • Playing around a bit datapoint 109 just toggles all zones on or off - so I think you can eliminate that.
  • Defining 108 as a number in esphome, the logs show the datapoint being set, but it doesn’t seem to do anything, the datapoint resets to 0 on the next update cycle, but perhaps I’m not setting a valid value?
  • Could 107 be useful ? Hex FF is 255. You could experiment with setting this, I didn’t bother.

It might just be easier to just add some logic to detect this either in ESPhome or Home assistant and handle it by turning the zone back on … say using a “on_datapoint_update” automation in your config.

As I don’t need this functionality I probably won’t pursue this futher unless I get have a revelation about what it could be, but let me know if you make progress.

1 Like

Thanks alot for taking the time to reply, really do appreciate it.
The logs look like it isnt HA turning it off, and it is something outside HA. Im starting to thing it may be something on the actual PCB itself, but need to take some time myself to look at this.

In the meantime, I just created a script to loop the one 3 times to make up the 30min ( its a garden irrigation).
Ill keep at i, and if i have a eureka moment, Ill let you know. But look at your reply, Im guessing you already know more than me :slight_smile:

I only needed to ground the GPIO0. Created the firmware directly in ESPHOME and installed it via the browser. Once it was uploaded, I then went ahead and modified it accordingly. I soldered it cause I couldnt get a reliable connection the other way.

10 min limit exist with original firmware and tuya when used with manual (with timer there is no limit)

Do you find a way to remove this limit?

Thanks.

I don’t need more than 10minutes, but @BEAVERTEETH1978 decided to use a script to switch on the circuit multiple times to make up the required time.

Any chance that you can flash tasmota firmware on this device?
really disappointed that the tuya integration does not allow proper control to the device, i got the device added but no controls. and i really need to get this device in HA as i need it to control a solenoid for my well pump/filter

I have attempted the above but have not been successful in flashing this device.
I noticed i have a WB3S device after trying diffirent rx/tx connections and even getting the pinout of the device and soldering the wires directly to it.

The closest i got to some kind of result was an error in ESPEasy espcomm_send_command: wrong direction/command: 0x00 0x08, expected 0x01 0x08

and i tried using Beken WriterV1.60 with an error message deprotection flashFAILED

Any one got any suggestions, i would really appreciate it