zigbeefordomoticz / Domoticz-Zigbee

Zigbee plugin for Domoticz. Allow to connect various zigbee controllers like Zigate but also Texas Instrument CC2531, CC13x2, CC26x2 ; Silicon-Labs; deConz based chipset to be connected to Domoticz
GNU General Public License v3.0
102 stars 43 forks source link

Model ZTH01 manufactured by Tuya #1761

Closed timmpo closed 4 months ago

timmpo commented 4 months ago

Temperature and Humidity Sensor Model ZTH01 manufactured by Tuya https://zigbee.blakadder.com/Tuya_ZTH01.html

good thing is that all the data is in place, but not in the right place. logs..

INFO:Device 0xfe99 (a4:c1:38:ad:a1:86:01:e8) joined the network INFO:b'tuyaReadRawAPS - fe99/01 fcf: 09 sqn: 67 cmd: 02 Payload: 09670201bd01020004000000e4' INFO:b'tuya_responsee - Model: TS0601 Nwkid: fe99/01 dp: 01 dt: 02 data: 000000e4' <------Temperature in celsius INFO:b'tuya_responsee - Model: TS0601 Nwkid: fe99/01 dp: 02 dt: 02 data: 0000004b' <------ Hum in % INFO:b'tuya_responsee - Model: TS0601 Nwkid: fe99/01 dp: 03 dt: 04 data: 01' <------ Battery poor, 02 = Good INFO:b'tuya_responsee - Model: TS0601 Nwkid: fe99/01 dp: 09 dt: 04 data: 00' <------ Unknown?

it missidentifies as a wathertimer INFO:b'tuya_watertimer_response - Model: TS0601 Nwkid: fe99/01 dp: 03 data type: 04 data: 01'

the sensor data ends here: tuya.py in function tuya_response line 308 elif _ModelName in ("TS0601-Parkside-Watering-Timer"): tuya_watertimer_response( self, Devices, _ModelName, NwkId, srcEp, ClusterID, dstNWKID, dstEP, dp, datatype, data ) export(5).json

timmpo commented 4 months ago

i have done some investigating.... added _TZE204_yjjdcqsq in line 59 in tuyaConst.py changed line 1302 in tuya.py to: and self.ListOfDevices[ NwkId ][ 'Manufacturer Name' ] not in ( '_TZE200_qoy0ekbd', '_TZE200_whkgqxse','_TZE204_yjjdcqsq') so it dont trigger the if statment (humi /= 10) the value needs not be divided.

added:

    elif dp == 0x03:   # Battery _TZE204_yjjdcqsq 01=poor 02=good
        batt = int(data, 16)
        if (batt == 1):
            batt = "0"
        else:
            batt = "64" # 16 bit hex to dec = 100
        store_tuya_attribute(self, NwkId, "Battery", batt)
        checkAndStoreAttributeValue(self, NwkId, "01", "0001", "0000", int(batt, 16))
        self.ListOfDevices[NwkId]["Battery"] = int(batt, 16)
        Update_Battery_Device(self, Devices, NwkId, int(batt, 16))
        store_tuya_attribute(self, NwkId, "BatteryStatus", batt)

at line 1308 (tuya.py) for battery

added "TS0601-_TZE200_nklqjk62", in line 685 in pairingProcess.py

it now works, but i did this only for test the sensor, this changes must be confirmed or redone the right whay.

I hooked the sensor up to a bench power supply and turn down the voltage, and the dp: 03 changed from 02 to 01 so i believe that is the battery state good/bad.

One more finding, i believe the sensor is verry sensitive from interference when paring, i have an inverter in the same room and i cant pair that sensor when the inverter is on the grid. i have never had problem with another device.

pipiche38 commented 4 months ago

can you try to upgrade to [5.286] as for the Certified Db.

you can do it by doing sudo python3 -m pip install -r requirements.txt --upgrade

and then restart the plugin, this is a much flexible way to integrate this device that changing some of the plugin code

As you can see they are several Tuya Temp/Humi config. I guess one should work with yours (for now I have added your config to TS0601-temphumi, but they are already 2 others possibles one).

https://github.com/zigbeefordomoticz/z4d-certified-devices/blob/main/z4d_certified_devices/Certified/Tuya/TS0601-temphumi.json https://github.com/zigbeefordomoticz/z4d-certified-devices/blob/main/z4d_certified_devices/Certified/Tuya/TS0601-temphumi-2.json https://github.com/zigbeefordomoticz/z4d-certified-devices/blob/main/z4d_certified_devices/Certified/Tuya/TS0601-temphumix10.json

If you want to play around you can simply copy the TS0601-temphumix10.json file into the plugin Conf/Local-Devices and it will overwrite the standard config.

PS/ I tried to document as much possible, but they are still work to do https://github.com/zigbeefordomoticz/wiki/blob/master/en-eng/HowTo_Device-Customization-TS0601.md https://github.com/zigbeefordomoticz/wiki/blob/master/en-eng/HowTo_Device-Customization.md

timmpo commented 4 months ago

i upgrade to Plugin: 7.1.012 [5.287] now the sensor works without messing around

pipiche38 commented 4 months ago

Super ...