dresden-elektronik / deconz-rest-plugin

deCONZ REST-API plugin to control ZigBee devices
BSD 3-Clause "New" or "Revised" License
1.89k stars 496 forks source link

Request for Tuya Smart Zigbee Temp and Humidity Sensor manu:"_TZ3000_bjawzodf" / model: "TY0201" #7884

Closed GitHubStephan closed 6 days ago

GitHubStephan commented 1 month ago

Is there already an existing issue for this?

Product name

Tuya Smart Zigbee Temp and Humidity Sensor

Manufacturer

_TZ3000_bjawzodf

Model identifier

TS0201

Device type to add

Sensor

Node info

image

Endpoints and clusters

image

Basic

image

Further relevant clusters

Power Configuration

On/Off

Level Control

Color Control

Thermostat

Simple Metering

Electrical Measurement

Any other cluster of relevance/interest

GitHubStephan commented 1 month ago

there is already a "quirk" for this device in ZHA but i dont know if its possible to convert a quirk in a DDF: https://github.com/zigpy/zha-device-handlers/issues/2862

GitHubStephan commented 3 weeks ago

Hab jetzt die json von einem ähnlichen Gerät genommen und Manufacturer angepasst. Einlesen in Phoson war erfolgreich und Daten werden gelesen und aktualisiert. Ich werde mal bis heute Abend beobachten, ob die Daten konsequent weiter im Systen ankommen.

{
  "schema": "devcap1.schema.json",
  "manufacturername": "_TZ3000_bjawzodf",
  "modelid": "TY0201",
  "vendor": "Tuya",
  "product": "Temperature and humidity locked sensor",
  "sleeper": true,
  "status": "Gold",
  "subdevices": [
    {
      "type": "$TYPE_TEMPERATURE_SENSOR",
      "restapi": "/sensors",
      "uuid": [
        "$address.ext",
        "0x01",
        "0x0402"
      ],
      "items": [
        {
          "name": "attr/id"
        },
        {
          "name": "attr/lastannounced"
        },
        {
          "name": "attr/lastseen"
        },
        {
          "name": "attr/manufacturername"
        },
        {
          "name": "attr/modelid"
        },
        {
          "name": "attr/name"
        },
        {
          "name": "attr/swversion",                   
          "parse": {"fn": "zcl:attr", "ep": 1, "cl": "0x0000", "at": "0x0001", "script": "tuya_swversion.js"},
          "read": {"fn": "zcl:attr", "ep": 1, "cl": "0x0000", "at": "0x0001"}
        },
        {
          "name": "attr/type"
        },
        {
          "name": "attr/uniqueid"
        },
        {
          "name": "config/battery",
          "awake": true,
          "parse": {
            "at": "0x0021",
            "cl": "0x0001",
            "ep": 1,
            "eval": "Item.val = Attr.val / 2;",
            "fn": "zcl:attr"
          }
        },
        {
          "name": "config/offset"
        },
        {
          "name": "config/on"
        },
        {
          "name": "config/reachable"
        },
        {
          "name": "config/tuya_unlock"
        },
        {
          "name": "state/lastupdated"
        },
        {
          "name": "state/temperature",
          "awake": true
        }
      ]
    },
    {
      "type": "$TYPE_HUMIDITY_SENSOR",
      "restapi": "/sensors",
      "uuid": [
        "$address.ext",
        "0x01",
        "0x0405"
      ],
      "items": [
        {
          "name": "attr/id"
        },
        {
          "name": "attr/lastannounced"
        },
        {
          "name": "attr/lastseen"
        },
        {
          "name": "attr/manufacturername"
        },
        {
          "name": "attr/modelid"
        },
        {
          "name": "attr/name"
        },
        {
          "name": "attr/swversion",                   
          "parse": {"fn": "zcl:attr", "ep": 1, "cl": "0x0000", "at": "0x0001", "script": "tuya_swversion.js"},
          "read": {"fn": "zcl:attr", "ep": 1, "cl": "0x0000", "at": "0x0001"}
        },
        {
          "name": "attr/type"
        },
        {
          "name": "attr/uniqueid"
        },
        {
          "name": "config/battery",
          "awake": true,
          "parse": {
            "at": "0x0021",
            "cl": "0x0001",
            "ep": 1,
            "eval": "Item.val = Attr.val / 2;",
            "fn": "zcl:attr"
          }
        },
        {
          "name": "config/offset"
        },
        {
          "name": "config/on"
        },
        {
          "name": "config/reachable"
        },
        {
          "name": "state/humidity",
          "awake": true
        },
        {
          "name": "state/lastupdated"
        }
      ]
    }
  ],
  "bindings": [
    {
      "bind": "unicast",
      "src.ep": 1,
      "cl": "0x0001",
      "report": [
        {
          "at": "0x0021",
          "dt": "0x20",
          "min": 3600,
          "max": 84600,
          "change": "0x00000002"
        }
      ]
    },
    {
      "bind": "unicast",
      "src.ep": 1,
      "cl": "0x0402",
      "report": [
        {
          "at": "0x0000",
          "dt": "0x29",
          "min": 60,
          "max": 300,
          "change": "0x00000064"
        }
      ]
    },
    {
      "bind": "unicast",
      "src.ep": 1,
      "cl": "0x0405",
      "report": [
        {
          "at": "0x0000",
          "dt": "0x21",
          "min": 60,
          "max": 300,
          "change": "0x00000064"
        }
      ]
    }
  ]
}
Smanar commented 3 weeks ago

Hello, there is the model _TZE200_bjawzodf in this DDF https://github.com/dresden-elektronik/deconz-rest-plugin/blob/master/devices/tuya/_TZE200_bjawzodf_humidity_temp.json Can you try to add your model to this list ? probably one more clone ?

But honneslty your DDf is better, this one miss the bind/report. I think it's better to mix the 2 DDF if they are compatibles.

Edit: Have found a more generic DDF https://github.com/dresden-elektronik/deconz-rest-plugin/blob/master/devices/tuya/_TZE200_TS0601_humidity_temp.json And this one haven't the bind/report part too, perhaps not usefull for tuya.

Edit2: I think I have found the better DDF ^^ to add your device https://github.com/dresden-elektronik/deconz-rest-plugin/blob/master/devices/tuya/_TZ3000_TS0201_temp_hum_sensor.json

GitHubStephan commented 3 weeks ago

Thanks, the last one you found is the same i used at the end. Since this morning its working without issues. For me topic is solved. Perhaps someone can start a PR with my modified code. I dont know how to do.

Smanar commented 3 weeks ago

Sure https://github.com/dresden-elektronik/deconz-rest-plugin/pull/7889 As you have used the same DDF, have just added your device to the list, thx for report and tests.

GitHubStephan commented 3 weeks ago

one fault on my side. i started the thread with Model identifier : TS0201. That was not correct. it is TY0201 (was a typo). can you pls correct it in the PR? sorry for the extra work

Smanar commented 3 weeks ago

Np, PR updated

RneeJ commented 1 week ago

using deCONZ v2.28.1 with ConbeeII.

I have "manufacturername": "_TZ3210_ncw88jfq", "modelid": "TS0201", Is ali/tuya temperature/humidity sensor for € 4,50. I used the json from Stefan.

Had to place it in usr/../devices.... $home/.local... doesn't get read at startup/reboot etc.

Works well, is recognized in deCONZ and Phoscon App as a sensor (temperature/humidity) .

Humidity is reported wrong 6,3 % instead of 63 %. Can i change that in the .json ? Or any other idea ?

Smanar commented 1 week ago

I don't don't found another DDF as sample, but for you better to create a new DDF instead of using an old one and change this part


        {
          "name": "state/humidity",
          "awake": true
        },

by


{
  "name": "state/humidity",
  "parse": {
    "at": "0x0000",
    "cl": "0x0405",
    "ep": 1,
    "eval": "Item.val = Attr.val * 10 + R.item('config/offset').val",
    "fn": "zcl:attr"
  },
  "default": 0
}
RneeJ commented 1 week ago

Thank you Smanar ! , i figured that out but changed to : { "name": "state/humidity", "awake": true, "parse": { "at": "0x0000", "cl": "0x0405", "ep": 0, "eval": "Item.val = Attr.val * 10 + R.item('config/offset').val", "fn": "zcl:attr" }, "default": 0 },

I also added battery reading { "name": "config/battery", "refresh.interval": 7265, "read": { "at": "0x0021", "cl": "0x0001", "ep": 1, "fn": "zcl:attr" }, "parse": { "at": "0x0021", "cl": "0x0001", "ep": 1, "eval": "Item.val = Attr.val / 2" }, "default": 0

2024-08-30 17-36-12

Smanar commented 1 week ago

Ha ? the previous battery reading was not working ? If all is fine can make a PR to submit the device ? Or want I make it ? (if you share the complete working DDF)

RneeJ commented 1 week ago

@Smanar thank you. you can add the device to the mentioned json. I can’t make a PR. I just started last week with DeCONZ, Zigbee etc. I still have to learn about them. Neither do i have experience with Github. i am also working on some other sensors i bought.

Smanar commented 1 week ago

Can you copy/paste the full working DDF ? It prevent typo if I make the PR

RneeJ commented 1 week ago

Directly from DeCONZ

_TZ3210_ncw88jfq_temp-hum-sensor.json

The temperature at cluster 0402 id 0000 is 2550 but reported on Phoscon App as 25. It misses the digits behind the comma. Also Min/max measurement is not show in the Phoscon App. afbeelding

Smanar commented 1 week ago

Min and Max are not displayed in phoscon, but decimal need to be visible, can you check direclty in the API ? Using Phoscon/help/API Information/sensors

PR created https://github.com/dresden-elektronik/deconz-rest-plugin/pull/7908

Have edited some stuff, like the missing bind/report for battery, so have used defaut code with.

RneeJ commented 1 week ago

Phoscon/help/API Information/sensors : afbeelding

But in http://192.168.2.32:8080/pwa/devices-sensors2.html?_v=8af8975ffa0c93c20a8c5db60e99f4a70b44c8c5,8,1,19&gwid=00212EFFFF09D402#sensor/3

afbeelding

Also 25 and not 25,7

Smanar commented 1 week ago

Ok so the issue is from Phoscon, not the API. IDK why they have made this choice. Here I can do nothing ....