question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Device Support Request] Tuya TS0601 - TZE200_81isopgh - Garden Watering System

See original GitHub issue

Hello, first of all, thanks for your future help :p

Is your feature request related to a problem? Please describe. I buy this product to manage my garden watering system : https://www.domadoo.fr/fr/peripheriques/5886-saswell-electrovanne-et-programmateur-d-arrosage-connecte-zigbee-mesure-de-consommation.html

It’s not recognized by ZHA and I started a quirks, with some tries, I managed to have the on_off working ! Yeah ! I would like to go further, because I know that it reports the consummed water (I hope because it was specified)

Actual Quirks
"""Tuya Garden Watering"""

from zigpy.profiles import zha
from zigpy.quirks import CustomDevice
from zigpy.zcl.clusters.general import Basic, Groups, Ota, Scenes, Time

from zhaquirks.const import (
    DEVICE_TYPE,
    ENDPOINTS,
    INPUT_CLUSTERS,
    MODELS_INFO,
    OUTPUT_CLUSTERS,
    PROFILE_ID,
)

from zhaquirks.tuya import TuyaManufCluster
from zhaquirks.tuya.mcu import MoesSwitchManufCluster, TuyaOnOff, TuyaOnOffManufCluster


class TuyaGardenWatering(CustomDevice):
    """Tuya Garden Watering"""

    signature = {
        MODELS_INFO: [("_TZE200_81isopgh", "TS0601")],
        ENDPOINTS: {
            1: {
                PROFILE_ID: zha.PROFILE_ID,
                DEVICE_TYPE: zha.DeviceType.SMART_PLUG,
                INPUT_CLUSTERS: [
                    Basic.cluster_id,
                    Groups.cluster_id,
                    Scenes.cluster_id,
                    TuyaOnOffManufCluster.cluster_id,
                ],
                OUTPUT_CLUSTERS: [Time.cluster_id, Ota.cluster_id],
            }
        },
    }

    replacement = {
        ENDPOINTS: {
            1: {
                DEVICE_TYPE: zha.DeviceType.SMART_PLUG,
                INPUT_CLUSTERS: [
                    Basic.cluster_id,
                    Groups.cluster_id,
                    Scenes.cluster_id,
                    TuyaManufCluster.cluster_id,
                    TuyaOnOffManufCluster,
                    TuyaOnOff,
                ],
                OUTPUT_CLUSTERS: [Time.cluster_id, Ota.cluster_id],
            }
        }
    }

Describe the solution you’d like I would like some help to get further, I’m not familiar with quirks and python (I’m .net, nobody is perfect :p)

Device signature - this can be acquired by clicking on the "Zigbee Device Signature" button in the device settings
{
  "node_descriptor": "NodeDescriptor(logical_type=<LogicalType.EndDevice: 2>, complex_descriptor_available=0, user_descriptor_available=0, reserved=0, aps_flags=0, frequency_band=<FrequencyBand.Freq2400MHz: 8>, mac_capability_flags=<MACCapabilityFlags.AllocateAddress: 128>, manufacturer_code=4098, maximum_buffer_size=82, maximum_incoming_transfer_size=82, server_mask=11264, maximum_outgoing_transfer_size=82, descriptor_capability_field=<DescriptorCapability.NONE: 0>, *allocate_address=True, *is_alternate_pan_coordinator=False, *is_coordinator=False, *is_end_device=True, *is_full_function_device=False, *is_mains_powered=False, *is_receiver_on_when_idle=False, *is_router=False, *is_security_capable=False)",
  "endpoints": {
    "1": {
      "profile_id": 260,
      "device_type": "0x0051",
      "in_clusters": [
        "0x0000",
        "0x0004",
        "0x0005",
        "0x0006",
        "0xef00"
      ],
      "out_clusters": [
        "0x000a",
        "0x0019"
      ]
    }
  },
  "manufacturer": "_TZE200_81isopgh",
  "model": "TS0601",
  "class": "ts0601_garden.TuyaGardenWatering"
}
Diagnostic information - this can be acquired by clicking on the "Download Diagnostics" button in the device settings
{
  "home_assistant": {
    "installation_type": "Home Assistant OS",
    "version": "2022.5.3",
    "dev": false,
    "hassio": true,
    "virtualenv": false,
    "python_version": "3.9.9",
    "docker": true,
    "arch": "x86_64",
    "timezone": "Europe/Brussels",
    "os_name": "Linux",
    "os_version": "5.10.108",
    "supervisor": "2022.05.1",
    "host_os": "Home Assistant OS 7.6",
    "docker_version": "20.10.9",
    "chassis": "embedded",
    "run_as_root": true
  },
  "custom_components": {
    "hacs": {
      "version": "1.24.5",
      "requirements": [
        "aiogithubapi>=21.11.0"
      ]
    },
    "adaptive_lighting": {
      "version": "1.0.14",
      "requirements": []
    },
    "nodered": {
      "version": "1.0.8",
      "requirements": []
    },
    "xiaomi_cloud_map_extractor": {
      "version": "v2.1.5",
      "requirements": [
        "pillow",
        "pybase64",
        "python-miio",
        "requests",
        "pycryptodome"
      ]
    },
    "auto_backup": {
      "version": "1.0.1",
      "requirements": []
    },
    "spotcast": {
      "version": "v3.6.29",
      "requirements": [
        "spotify_token==1.0.0"
      ]
    }
  },
  "integration_manifest": {
    "domain": "zha",
    "name": "Zigbee Home Automation",
    "config_flow": true,
    "documentation": "https://www.home-assistant.io/integrations/zha",
    "requirements": [
      "bellows==0.29.0",
      "pyserial==3.5",
      "pyserial-asyncio==0.6",
      "zha-quirks==0.0.73",
      "zigpy-deconz==0.16.0",
      "zigpy==0.45.1",
      "zigpy-xbee==0.14.0",
      "zigpy-zigate==0.7.4",
      "zigpy-znp==0.7.0"
    ],
    "usb": [
      {
        "vid": "10C4",
        "pid": "EA60",
        "description": "*2652*",
        "known_devices": [
          "slae.sh cc2652rb stick"
        ]
      },
      {
        "vid": "10C4",
        "pid": "EA60",
        "description": "*sonoff*plus*",
        "known_devices": [
          "sonoff zigbee dongle plus"
        ]
      },
      {
        "vid": "10C4",
        "pid": "EA60",
        "description": "*tubeszb*",
        "known_devices": [
          "TubesZB Coordinator"
        ]
      },
      {
        "vid": "1A86",
        "pid": "7523",
        "description": "*tubeszb*",
        "known_devices": [
          "TubesZB Coordinator"
        ]
      },
      {
        "vid": "1A86",
        "pid": "7523",
        "description": "*zigstar*",
        "known_devices": [
          "ZigStar Coordinators"
        ]
      },
      {
        "vid": "1CF1",
        "pid": "0030",
        "description": "*conbee*",
        "known_devices": [
          "Conbee II"
        ]
      },
      {
        "vid": "10C4",
        "pid": "8A2A",
        "description": "*zigbee*",
        "known_devices": [
          "Nortek HUSBZB-1"
        ]
      },
      {
        "vid": "10C4",
        "pid": "8B34",
        "description": "*bv 2010/10*",
        "known_devices": [
          "Bitron Video AV2010/10"
        ]
      }
    ],
    "codeowners": [
      "@dmulcahey",
      "@adminiuga"
    ],
    "zeroconf": [
      {
        "type": "_esphomelib._tcp.local.",
        "name": "tube*"
      }
    ],
    "after_dependencies": [
      "usb",
      "zeroconf"
    ],
    "iot_class": "local_polling",
    "loggers": [
      "aiosqlite",
      "bellows",
      "crccheck",
      "pure_pcapy3",
      "zhaquirks",
      "zigpy",
      "zigpy_deconz",
      "zigpy_xbee",
      "zigpy_zigate",
      "zigpy_znp"
    ],
    "is_built_in": true
  },
  "data": {
    "ieee": "**REDACTED**",
    "nwk": 34622,
    "manufacturer": "_TZE200_81isopgh",
    "model": "TS0601",
    "name": "_TZE200_81isopgh TS0601",
    "quirk_applied": true,
    "quirk_class": "ts0601_garden.TuyaGardenWatering",
    "manufacturer_code": 4098,
    "power_source": "Battery or Unknown",
    "lqi": 142,
    "rssi": null,
    "last_seen": "2022-05-10T19:52:04",
    "available": true,
    "device_type": "EndDevice",
    "signature": {
      "node_descriptor": "NodeDescriptor(logical_type=<LogicalType.EndDevice: 2>, complex_descriptor_available=0, user_descriptor_available=0, reserved=0, aps_flags=0, frequency_band=<FrequencyBand.Freq2400MHz: 8>, mac_capability_flags=<MACCapabilityFlags.AllocateAddress: 128>, manufacturer_code=4098, maximum_buffer_size=82, maximum_incoming_transfer_size=82, server_mask=11264, maximum_outgoing_transfer_size=82, descriptor_capability_field=<DescriptorCapability.NONE: 0>, *allocate_address=True, *is_alternate_pan_coordinator=False, *is_coordinator=False, *is_end_device=True, *is_full_function_device=False, *is_mains_powered=False, *is_receiver_on_when_idle=False, *is_router=False, *is_security_capable=False)",
      "endpoints": {
        "1": {
          "profile_id": 260,
          "device_type": "0x0051",
          "in_clusters": [
            "0x0000",
            "0x0004",
            "0x0005",
            "0x0006",
            "0xef00"
          ],
          "out_clusters": [
            "0x000a",
            "0x0019"
          ]
        }
      }
    },
    "entities": [
      {
        "entity_id": "switch.tze200_81isopgh_ts0601_a2d496fe_on_off",
        "name": "_TZE200_81isopgh TS0601"
      }
    ],
    "neighbors": [],
    "endpoint_names": [
      {
        "name": "SMART_PLUG"
      }
    ],
    "user_given_name": "Arrosage",
    "device_reg_id": "c0fcf22479dc276b1786a1351bdd7c8c",
    "area_id": "garage"
  }
}
Additional logs
Don't know what I can send, but ask me, I'll post what you need :)

Additional context Haha … I understand the principle of quirks and I can read the python code … I don’t know how to find the right value without try and try and try and try again …

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:1
  • Comments:16 (10 by maintainers)

github_iconTop GitHub Comments

2reactions
simonbaudartcommented, May 16, 2022

Ok, it’s updated ! I’ve checked and I see the value in the cluster attributes in HA

image

1reaction
dmulcaheycommented, May 16, 2022

I was asking in the PR about the Timer cluster because I don’t see any advantage in the approach to separate the timer values into made up cluster.

class TuyaValveTimer(TuyaAttributesCluster):
    """Timer cluster."""

    cluster_id = 0x043E
    name = "Timer"
    ep_attribute = "timer"

    attributes = {
        0x000C: ("state", t.uint16_t),
        0x000B: ("time_left", t.uint16_t),
        0x000F: ("last_valve_open_duration", t.uint16_t),
    }

In HA frontend there are not entities which made to match this cluster. Of course you can create them by yourself, but it is not standard so anybody in the future implementing a timer has to find this quirk.

I was advised to use different approach. Do not create a new made up cluster, but add those values into your TuyaValveManufCluster cluster. Like here:

class TuyaWaterValveManufCluster(TuyaMCUCluster):

    attributes = TuyaMCUCluster.attributes.copy()
    attributes.update(
        {
            0xef01: ("timer", t.uint32_t, True),
            0xef02: ("timer_time_left", t.uint32_t, True),
            0xef03: ("frost_lock", t.Bool, True),
            0xef04: ("frost_lock_reset", t.Bool, True),  # 0 resets frost lock
        }
    )

    dp_to_attribute: Dict[int, DPToAttributeMapping] = {
            5: DPToAttributeMapping(
                TuyaMCUCluster.ep_attribute,
                "timer",
                TuyaDPType.VALUE,
            ),
    }

This will reduce bit from the code complexity and after small change to HA frontend (which I have do for my lidl valve) the timer entities will be there.

This is the correct way to do this

Read more comments on GitHub >

github_iconTop Results From Across the Web

ZHA Quirk for Tuya Garden Water Valve TS0601 ...
I bought this Garden water valve and I cannot get it to run: Zigbee Wifi Garden Watering Timer Smart Sprinkler Drip Irrigation System...
Read more >
Request for help for Tuya Water valve - DTH and EDGE driver
Hi, I am looking for some help developing a DTH for a Tuya Water valve (which screws on to a tap for irrigation...
Read more >
User Guide-Tuya IoT Development Platform-Tuya Developer
This topic describes how to use the Smart Life app . Download the app. Search for Smart Life in Apple's App Store and...
Read more >
Support new TuYa devices - Zigbee2MQTT
# 2. Adding your device. Adding support for TuYa devices is a bit different. In order to provide support for E.G. the TS0601...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found