Zigbee temperature sensor & switch only detected as "light"

I’m really new to this so please be patient!

Thanks Suggsy and klib , I’ve just bought 3 of these devices particularly for the remote temperature sensor and can’t get to work. Your post is exactly what I needed and I’ve installed the “quirk” but I can’t get it to work either.

On reboot HA reported an error in the quirk filepath so I added 2 spaces before the second line in the configuration.yaml file so it now looks like this and the error on reboot has gone, but I’m not sure if the quirk is loading correctly.

Loads default set of integrations. Do not remove.

default_config:

Load frontend themes from the themes folder

frontend:
themes: !include_dir_merge_named themes

automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml

Example configuration.yaml entry

zeroconf:

for nginx

http:
use_x_forwarded_for: true
trusted_proxies:
- 172.30.33.0/24

zha:
custom_quirks_path: /config/zha_quirks/

Also, the raw file I downloaded is called

homeassistant/zha_quirks/ab0188dd-b8d9-42d6-9c19-483aabd51974.txt

And not

candeo_smart_irrigation_timer.py

But the code looks the same - should I download another file from somewhere?
How can I check that the quirk is loaded and running?

Thanks

1 Like

I created an account here just to thank you for this quirk. A lifesaver.

I also changed the line 93 to: DEVICE_TYPE: zha.DeviceType.SMART_PLUG,

This changes the relay from light switch to a generic switch. If needed, it can be easily converted back to light (or whatever) in the device config in HA, but as a light, it’s not that easy to convert it to anything else.

Anyone has instructions on how/where to submit this and make it official?

1 Like

You downloaded a text version of a python files, so it won’t be recognised. You need to rename the file from .txt to .py for it to have a chance of being picked up.

Glad my quirk helped you, and you’re absolutely right, it is better configured as a switch than as a light. For me it didn’t matter but it’s neater your way.

Has anyone tried this device in the native Tuya ecosystem? Does the little light indicate on/off state of the switch or is it always on as with ZHA? If it is the former maybe i can try and adopt the quirk for this as well using TuyaZBOnOffAttributeCluster.

After a bit of research, it looks like the indicator light it not meant to show the status of the relay/switch. Apparently it’s a network connectivity indicator.

On the other hand, there are some settings available in the Tuya app that would be nice to have in HomeAssistant (ZHA). Units, calibration, sensitivity, restart status, child lock… Time to read some ZHA documentation :wink:

(image coming in the next post…)

Image related to the previous post (new user embed image limitations…)

Maybe not the answer you were looking for, but all those (except Units) are supported in Z2MQTT :wink:

1 Like

Good to know. Although, i’m not really in the mood for migrating Zigbee2MQTT…
This gives me hope that making it work in ZHA is doable :wink:

1 Like

This works for me!!!

Is there a way to add humidity to?

I have added the humidity values.

TS000F_TZ3218_7fiyo3kv.py

image

3 Likes

Thanks all, just received mine and will go through your suggestions on this thread to get it working.

I have submitted a official request for this unit (I have the humidity version, but I have asked for both to be supported)

https://github.com/zigpy/zha-device-handlers/issues/3950

Here is the zha quirks file I had to use to get this working. The above code was close, but I had to make a few tweaks to get this working for this device https://www.amazon.com/dp/B0DF7KZ4GT which uses Tuya TS000F _TZ3218_7fiyo3kv

"""tuya TS000F _TZ3218_7fiyo3kv On/Off In-line Switches with thermometer and humidity support."""

from zigpy.profiles import zgp, zha
from zigpy.zcl.clusters.general import (
    Basic,
    GreenPowerProxy,
    Groups,
    Identify,
    OnOff,
    Ota,
    Scenes,
    Time,
)
from zigpy.zcl.clusters.lightlink import LightLink
from zigpy.zcl.clusters.measurement import TemperatureMeasurement, RelativeHumidity

from zhaquirks.const import (
    DEVICE_TYPE,
    ENDPOINTS,
    INPUT_CLUSTERS,
    MODEL,
    OUTPUT_CLUSTERS,
    PROFILE_ID,
)
from zhaquirks.tuya import (
    EnchantedDevice,
    TuyaZBE000Cluster,
    TuyaZBOnOffAttributeCluster,
    TuyaLocalCluster,
    TuyaZBExternalSwitchTypeCluster,
)
from zhaquirks.tuya.mcu import DPToAttributeMapping, TuyaMCUCluster

class TuyaTemperatureMeasurement(TemperatureMeasurement, TuyaLocalCluster):
    """Tuya local TemperatureMeasurement cluster."""

class TuyaHumidityMeasurement(RelativeHumidity, TuyaLocalCluster):
    """Tuya local Relative Humidity Measurement cluster."""

class TemperatureHumidityManufCluster(TuyaMCUCluster):
    """Tuya Manufacturer Cluster with Temperature and Humidity data points."""

    dp_to_attribute: dict[int, DPToAttributeMapping] = {
        102: DPToAttributeMapping(
            TuyaTemperatureMeasurement.ep_attribute,
            "measured_value",
            converter=lambda x: x * 10,
        ),
        103: DPToAttributeMapping(
            TuyaHumidityMeasurement.ep_attribute,
            "measured_value",
            converter=lambda x: x * 100,
        ),
    }

    data_point_handlers = {
        102: "_dp_2_attr_update",
        103: "_dp_2_attr_update",
    }
        # ADDED: These attributes tell ZHA to request reporting for these clusters
    client_clusters = {
        TemperatureMeasurement,
        RelativeHumidity,
    }
    
    manufacturer_specific = {
        0xE001,
    }

class Tuya_1G_Switch_Temperature(EnchantedDevice):
    """Tuya 1 gang switch with temperature and humidity measurement."""

    signature = {
        MODEL: "TS000F",
        ENDPOINTS: {
            1: {
                PROFILE_ID: zha.PROFILE_ID,
                DEVICE_TYPE: zha.DeviceType.ON_OFF_LIGHT,
                INPUT_CLUSTERS: [
                    Basic.cluster_id,
                    Identify.cluster_id,
                    Groups.cluster_id,
                    Scenes.cluster_id,
                    OnOff.cluster_id,
                    TuyaZBE000Cluster.cluster_id,
                    TuyaZBExternalSwitchTypeCluster.cluster_id,
                    TemperatureHumidityManufCluster.cluster_id,
                ],
                OUTPUT_CLUSTERS: [Time.cluster_id, Ota.cluster_id],
            },
            242: {
                PROFILE_ID: zgp.PROFILE_ID,
                DEVICE_TYPE: zgp.DeviceType.PROXY_BASIC,
                INPUT_CLUSTERS: [],
                OUTPUT_CLUSTERS: [GreenPowerProxy.cluster_id],
            },
        },
    }
    replacement = {
        ENDPOINTS: {
            1: {
                PROFILE_ID: zha.PROFILE_ID,
                DEVICE_TYPE: zha.DeviceType.SMART_PLUG,
                INPUT_CLUSTERS: [
                    Basic.cluster_id,
                    Identify.cluster_id,
                    Groups.cluster_id,
                    Scenes.cluster_id,
                    TuyaZBOnOffAttributeCluster,
                    TuyaZBE000Cluster,
                    TuyaZBExternalSwitchTypeCluster,
                    TemperatureHumidityManufCluster,
                    TuyaTemperatureMeasurement,
                    TuyaHumidityMeasurement,
                ],
                OUTPUT_CLUSTERS: [Time.cluster_id, Ota.cluster_id],
            },
            242: {
                PROFILE_ID: zgp.PROFILE_ID,
                DEVICE_TYPE: zgp.DeviceType.PROXY_BASIC,
                INPUT_CLUSTERS: [],
                OUTPUT_CLUSTERS: [GreenPowerProxy.cluster_id],
            },
        },
    }```
1 Like

Thanks @Naprosnia for the Quirk and @jfguenther for the change that got the Temperature and Humidity to work for me.

For anyone that has a similar version and needs Humidity as well as temp, here’s a dummy’s guide (i.e. for me when I need to do it again).
I have a Mumubiz Smart Switch TYZGHTH16A-D1RF with the detachable combined Temperature/Humidity sensor and this finally worked after much hair pulling and a steep learning curve.
I’m using standard Home Assistant Operating System (not Home Assistant Container etc) and standard Zigbee/ZHA (not Zigbee2MQTT) and had the device added to HA already, but was only showing as a light switch:

  1. See if you have “File editor” Add-on installed: it may be on the home page side bar or in HA side bar > [Settings] > [Add-ons] > [File editor] > [Open web UI]

  2. If “File Editor” is not installed either go to the this link:
    Link to Add-on: dashboard – My Home Assistant
    or [Settings] > [Add-ons] > [Add-on store] > search for “File editor”
    then
    [Install] > Decide if you want it in the side bar & if you want it to start on startup (I didn’t want either as I’ll rarely use them) > [Start] > [Open web UI]

  3. [File editor] > [Folder icon] > [configuration.yaml] > click on the coding page on the right > paste the following 2 lines at the bottom of the lines of code with a blank line above it, then > [“Save” icon] > [X=“Close” icon]:

zha:
** custom_quirks_path: /config/zha_quirks/**

  1. Open a new tab in your browser and go to @Naprosnia 's Quirk on Github:
    TS000F_TZ3218_7fiyo3kv.py
    then > [(download symbol)] = “Download raw file” > close the tab.

  2. [File editor] > [Folder icon] > [Folder icon with +] = new folder > New Folder Name: zha_quirks > OK

  3. [File editor] > [zha_quirks] folder > [(upload symbol)] = Upload File > [File] > Find the file that was downloaded (likely TS000F_TZ3218_7fiyo3kv.py) > [Open] > [OK]

  4. [File editor] > [zha_quirks] folder > [TS000F_TZ3218_7fiyo3kv.py] > add the following 9 lines of code (courtesy of @jfguenther) after line 59 (although that number might change to check with posts above to see where to insert them), leaving a blank line after it, then [Save icon]:


        # ADDED: These attributes tell ZHA to request reporting for these clusters
    client_clusters = {
        TemperatureMeasurement,
        RelativeHumidity,
    }
    
    manufacturer_specific = {
        0xE001,
    }

  1. Make sure your thermometer/humidity probe is attached and the device has power.

  2. HA side bar > [Settings] > [⋮] = Menu > [Restart Home Assistant] > [Restart Home Assistant]

  3. Check if the sensors show up: HA side bar > [Settings] > [Devices and Services] > [Integrations] tab > [Zigbee Home Automation] > Click on the device.
    There should now be “Controls” with an On/Off switch and a “Sensors” card with temperature and humidity readings.