Koenkk / zigbee2mqtt

Zigbee 🐝 to MQTT bridge 🌉, get rid of your proprietary Zigbee bridges 🔨
https://www.zigbee2mqtt.io
GNU General Public License v3.0
11.77k stars 1.64k forks source link

Tuya / Whitelabel / ZONNSMART TV01-ZG radiator thermostat #8522

Closed drdownload closed 2 years ago

drdownload commented 3 years ago

Information about the device + link

Bought from this Link: https://de.aliexpress.com/item/1005002377522262.html?spm=a2g0s.9042311.0.0.4d6f4c4dEXD4cF

Found this Listing with reverse image search: https://expo.tuya.com/product/600974

data/database.db entry of the device

{"id":27,"type":"EndDevice","ieeeAddr":"0x84fd27fffe2dd98b","nwkAddr":18218,"manufId":4098,"manufName":"_TZE200_e9ba97vf","powerSource":"Battery","modelId":"TS0601","epList":[1],"endpoints":{"1":{"profId":260,"epId":1,"devId":81,"inClusterList":[0,4,5,61184],"outClusterList":[25,10],"clusters":{"genBasic":{"attributes":{"modelId":"TS0601","manufacturerName":"_TZE200_e9ba97vf","powerSource":3,"zclVersion":3,"appVersion":69,"stackVersion":0,"hwVersion":1,"dateCode":""}}},"binds":[],"configuredReportings":[],"meta":{}}},"appVersion":69,"stackVersion":0,"hwVersion":1,"dateCode":"","zclVersion":3,"interviewCompleted":true,"meta":{},"lastSeen":1629911314030}

Things I tried

I tried to add an external converter following the tuya specific guide.

first I tried with the default code from: https://www.zigbee2mqtt.io/how_tos/how_to_support_new_tuya_devices.html

then I copied the converter from the herdsman code that handles radiator thermostats and added the fingerprint.

however it always stays unsupported. I used this fingerprints: default config: fingerprint: [ { // The model ID from: Device with modelID 'TS0601' is not supported // You may need to add \u0000 at the end of the name in some cases modelID: 'TS0601', // The manufacturer name from: Device with modelID 'TS0601' is not supported. manufacturerName: '_TZE200_e9ba97v' }, ], model: 'TV01-ZG', vendor: 'ZONNSMART',

and herdsman converters code; zigbeeModel: ['TS601'], fingerprint: [{modelID: 'TS0601', manufacturerName: '_TZE200_e9ba97v'}], model: 'TS0601_thermostat', vendor: 'TuYa',

danieledwardgeorgehitchcock commented 3 years ago

Could you paste the full content of your external converter file as it is now?

drdownload commented 3 years ago

https://pastebin.com/9EmMRWPx

https://pastebin.com/uaH27qdA

I tried these 2

geoffreylagaisse commented 3 years ago

I want to add this excel screenshot. That I made while researching my quirck for zigpy image

danieledwardgeorgehitchcock commented 3 years ago

https://pastebin.com/9EmMRWPx

https://pastebin.com/uaH27qdA

I tried these 2

The fingerprint side of the external converter looks correct to me.. Are you sure you have referenced the file correctly in Zigbee2MQTT?

drdownload commented 3 years ago
data_path: /config/zigbee2mqtt
external_converters:
  - TV01-ZG.js
devices: devices.yaml

I added it like this and if I have an error like not including tuya herdsman crashes.

drdownload commented 3 years ago

image

geoffreylagaisse commented 3 years ago

You are missing a letter in your manufacturerName, it should be '_TZE200_e9ba97vf'

drdownload commented 3 years ago

man, thats embarassing, how many times have I copy and pasted and looked and compared ;)

drdownload commented 3 years ago

of course now it gets detected, now i need to look into how to control it ;)

geoffreylagaisse commented 3 years ago

I hope my sheet helps you a bit. I saw there isn't a Valve controler in this one

geoffreylagaisse commented 3 years ago

Maybe an easier way to share the excel: https://docs.google.com/spreadsheets/d/1X_Cve1MrWgeuhMAWxm60JRoAuN3MSv-g/edit?usp=sharing&ouid=107527359563098759211&rtpof=true&sd=true

drdownload commented 3 years ago

e.g. how do i read this (after changing some temp on the tv): Debug Received Zigbee message from '0x84fd27fffe2dd98b', type 'commandGetData', cluster 'manuSpecificTuya', data '{"data":{"data":[0,0,0,180],"type":"Buffer"},"datatype":2,"dp":16,"fn":0,"status":0,"transid":106}' from endpoint 1 with groupID 0

If I look at the adding tuya devices guide

    {name: 'status', type: DataType.uint8},
    {name: 'transid', type: DataType.uint8}, 
    {name: 'dp', type: DataType.uint8}, => 16
    {name: 'datatype', type: DataType.uint8}, => 2
    {name: 'fn', type: DataType.uint8}, => 0
    {name: 'data', type: DataType.octetStr}, => 0,0,0,180

since i set temp to 18 deg it makes sense. also 16 is temp in your excel sheet :)

if I look into tuya.js https://github.com/Koenkk/zigbee-herdsman-converters/blob/master/lib/tuya.js - dp 16 for heating would be a vendor specific dp: moesHeatingSetpoint: 16,

drdownload commented 3 years ago

or this one, pressing the boost button, setting it to 300 seconds of boost: Debug Received Zigbee message from '0x84fd27fffe2dd98b', type 'commandGetData', cluster 'manuSpecificTuya', data '{"data":{"data":[0,0,1,43],"type":"Buffer"},"datatype":2,"dp":101,"fn":0,"status":0,"transid":23}' from endpoint 1 with groupID 0

that would be moesSchedule: 101.

in your data sheet rapid temperature rise.

drdownload commented 3 years ago

Can I force the TV to send me all dp offered or do i need to try all of them on the TV?

geoffreylagaisse commented 3 years ago

Unfortunately no, you cannot force the device to give you all datepoints and info at once. I've gathered all info in the excel manually. The datepoints of Moes are a few digits different from this Zonnsmart device. You can use the template from moes to mirror yourself for this device, but ultimately the datapoints and endpoints will differ a bit.

For zigbee2mqtt you wont need the hex codes fortunatly

drdownload commented 3 years ago

Debug Received Zigbee message from '0x84fd27fffe2dd98b', type 'commandGetData', cluster 'manuSpecificTuya', data '{"data":{"data":[3],"type":"Buffer"},"datatype":4,"dp":2,"fn":0,"status":0,"transid":68}' from endpoint 1 with groupID 0 = mode

Debug Received Zigbee message from '0x84fd27fffe2dd98b', type 'commandGetData', cluster 'manuSpecificTuya', data '{"data":{"data":[1],"type":"Buffer"},"datatype":1,"dp":40,"fn":0,"status":0,"transid":85}' from endpoint 1 with groupID 0 = childlock

Debug Received Zigbee message from '0x84fd27fffe2dd98b', type 'commandGetData', cluster 'manuSpecificTuya', data '{"data":{"data":[0,0,0,170],"type":"Buffer"},"datatype":2,"dp":105,"fn":0,"status":0,"transid":85}' from endpoint 1 with groupID 0

it seems that come are the some, some similar and some different and if i lock and unlock directly after each other or change the temp rapidly i get no message with the most recent state

drdownload commented 3 years ago

Since I need (from what I see now) to extend ../fromZigbee.js for new/differently used DP, I need to create a PR after testing it locally.

however for testing I can create a local tozigbee.js and include it in my converter (at least i would try it ;) )

geoffreylagaisse commented 3 years ago

you will indeed need to extend those two files :-) Good Luck. If i missed in the datapoints somewhere, feel free to change it in the sheet and leave a comment or something!

drdownload commented 3 years ago

Based on what device did you create the excel? Exactly the same?

geoffreylagaisse commented 3 years ago

Yes, exactly the same! My PR for Zigpy-ZHA: https://github.com/zigpy/zha-device-handlers/pull/983

Krzysztonek commented 3 years ago

Guys, This converter works for me :) At least all thermostats have been detected and joined. Of course, one typo has been corrected ;) Thanks, @danieledwardgeorgehitchcock for sharing it :) #

Not yet checked if this is a fully manageable and programmable solution.

obraz

geoffreylagaisse commented 3 years ago

lol your used converter won't work correctly as this device uses other endpoints to manage its data. Zigbee2mqtt will show you the functionalities but they won't work or behave differently than they should. If @drdownload is up for it, he can program the correct endpoints for all data.

drdownload commented 3 years ago

I'm on it, @geoffreylagaisse : as you said, it's a total mixture of endpoints (moes, tuya default, saswell, new ones).

First version will one take care of stuff needed for "manual" mode, controlled by HA schedules.

Since it's my first commit/addition to zigbee2mqtt, it will take some time till I ironed out everything.

drdownload commented 3 years ago

Unfortunately no, you cannot force the device to give you all datepoints and info at once. I've gathered all info in the excel manually. The datepoints of Moes are a few digits different from this Zonnsmart device. You can use the template from moes to mirror yourself for this device, but ultimately the datapoints and endpoints will differ a bit.

For zigbee2mqtt you wont need the hex codes fortunatly

whats up with the "mode" column in your excel? is it the same as "datatype" in my datagrams?

E.g. my captured "set mode" 'manuSpecificTuya', data '{"data":{"data":[1],"type":"Buffer"},"datatype":4,"dp":2,"fn":0,"status":0,"transid":86}' however I dont see (yet) setting the datatype anywhere in the herdsman-converter

edit: found the datatype-mapping in tuya.js image

serrj-sv commented 3 years ago

check the top message of the issue 1803 , it can be useful. there is also a working converter

drdownload commented 3 years ago

thx, I'll have a look, I am curious if it will work ;) image

geoffreylagaisse commented 3 years ago

Hey @drdownload, How is the converter coming along?

dvovla commented 3 years ago

I'm very curious how this will turn out. I would also be very interested in battery life. I recently started with ZigBee. I only have zzh, one Saswell SEA802 trv and one IKEA outlet as a router. It works, but I'd rather buy a trv with a weekly program. I want them to work independently of the hub. I just want to remotely switch to economy mode (let 's say 17 °C all day). I will be grateful for your advice.

drdownload commented 2 years ago

Hi, will hopefully finish it on the weekend, I was away the last weeks.

drdownload commented 2 years ago

Hi, have not invested a lot time to be honest, but slowly coming together, eg. current heating setpoint.

image

My goal would be: battery, mode, childlock, local temperature, current setpoint, set current setpoint

edit: getting and setting current heating setpoint works, no idea why it does not pick up the battery.

drdownload commented 2 years ago
Krzysztonek commented 2 years ago

Fingers CROSSED, @drdownload! 🤞

drdownload commented 2 years ago

Debugging even for a type or some missconception how things are really a painful af with the feedback from herdsman, educated guess, and looking in the stuff like /lib/ etc. helps, but its a more complicated then i hoped for, just sitting on the couch on a sunday ;)

eg: the mode of the thermostat: auto, manual and vacation, also I can set low and high in auto. I have no idea where to put it in for config in expose ;)

its not systemMode const allowed = ['off', 'heat', 'cool', 'auto', 'dry', 'fan_only', 'sleep']; its not an away mode

maybe its a preset? I just dont know ;) of course I can extend everything as custom value, but that wouldnt be clean code

heres a similar discussion: https://github.com/Koenkk/zigbee-herdsman-converters/issues/1973

(the euronics spirit drove me crazy, there was a faulty batch, always draining the battery, becoming unresponsive, and I used them in my holiday home, and if the batteries were empty with the last power it opened the valve to 100 %.

drdownload commented 2 years ago

My converter would cover the basic functions to control from home assistant. only thing I dont get why I'm not getting any battery or local temperature dp (and have no idea to force them ;) )

image

Edit: I get the local_temperature and battery when pulling out the batteries, however I dont know if I will ever get an update ;)

Krzysztonek commented 2 years ago

Don't be put off by this minor dp disability, @drdownload . We're proud of you anyway. 👍 You're doing a great job! :)

geoffreylagaisse commented 2 years ago

I've seen the same behaviour when I programmed the quirck for ZHA. The temp update triggers when the valve opens or closes. The device then sends an update to the controller. Nice job @drdownload !

drdownload commented 2 years ago

yes, thanks for the confirmation, I just read somewhere, that battery is by default often only sent 1x per day. I also just received an temperature update, so it seems to work ;)

drdownload commented 2 years ago

has anyone a hint how to set up the temperature calibration?

this is +0.5 cluster 'manuSpecificTuya', data '{"data":{"data":[0,0,0,5],"type":"Buffer"},"datatype":2,"dp":27,"fn":0,"status":0,"transid":33}'

this is -0.5 cluster 'manuSpecificTuya', data '{"data":{"data":[255,255,255,250],"type":"Buffer"},"datatype":2,"dp":27,"fn":0,"status":0,"transid":16}

Edit: got it. Cheers to the converter of @serrj-sv, really, really great help and learning basis

image

drdownload commented 2 years ago

Here you go with the first version as external converter: https://gist.github.com/drdownload/b720bd1b179db04aea9cacb7d7360b46

What works: https://github.com/Koenkk/zigbee2mqtt/issues/8522#issuecomment-922465252

I orderd myself an Tuya Zigbee hub, maybe I can complete from the original implementation/package capture.

fun thing while I looked for a gateway, I stumpled upon this identical looking TRV (with the mention of "2MQTT setup available" image

drdownload commented 2 years ago

Since HA uses the operations/system mode for the lovelace card, and presets are hidden away:

Would it be good practice to do the following: if system mode is set to heat => manual preset with comfort temp if system mode is set to off => manual preset with eco temp if system mode is set to auto => schedule preset

drdownload commented 2 years ago

I've seen the same behaviour when I programmed the quirck for ZHA. The temp update triggers when the valve opens or closes. The device then sends an update to the controller. Nice job @drdownload !

@geoffreylagaisse : have you ever tried to start a boost period or send to freeze protection from zigbee2mqtt?

Krzysztonek commented 2 years ago

Hi there :)

Again, thank you guys for your great job! I've just installed this external converter, trying to do some exercises on one of my TV-01 thermostats.

I can read/display each entity's value: image

Unfortunately, I'm not able to change any values here. Not possible to control/change the settings of the device. Also, frost detection, heating stop, and window detection remain unchangeable. When trying to toggle them, they change for a second or two, and then they come back to the initial position. Seems the fromZigbee communication works ok, while toZigbee does not. This is my understanding, but I'm not an expert, just a stupid user ;)

I've also noticed, that the comfort temperature should be rather numerical value instead of boolean. Please see the above screen.

Am I doing anything wrong?

drdownload commented 2 years ago

Try to repair the device. also see the linked post what works and what doesnt. I have not yet figured out why I can only read eg. window detection but read and set the child lock. maybe the converter? I dont know.

regarding bedroom comfort temp, its not bool just not set therefore evaluating to false in HA. Have a look into the zigbee2mqtt webif

edit: just checked, never put in a converter for window_detection_set. edit2: I updated the gist with a working converter ro set window_detection

drdownload commented 2 years ago

I cleaned up the converter in the gist. Now only setable stuff is exposed.

Edit: My EcoTemp, ComfortTemp etc. are not ajustable in HA but in Z2M => no idea.

Krzysztonek commented 2 years ago

As I said, I'm not an expert, but it might be a bug in toZigbee code. Or there is a 'hidden' bug somewhere in the converter itself. I don't see any other options. Do you?

If so, then some investigation would be needed, but it will be difficult without Tuya hub. I believe , thanks @drdownload we're so close to the fully working solution...

drdownload commented 2 years ago

nope, the toZigbee code has nothing to do with home assistant.

Also I use it with home assistant with the version in the gist, controlling it in manual mode.

drdownload commented 2 years ago

image

image

image image

KrisMoro commented 2 years ago

Hi Tried to use your converter in HA Z2M addon, and got next repeatable error:

> > zigbee2mqtt@1.21.1 start
> > node index.js
> (node:834) UnhandledPromiseRejectionWarning: SyntaxError: Unexpected identifier
> (Use `node --trace-warnings ...` to show where the warning was created)
> (node:834) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
> (node:834) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Zigbee2mqtt Current version: 1.21.1-1

Can you please check?

drdownload commented 2 years ago

Hi, I copied the content of my working local container to the gist and updated, you can check again.

KrisMoro commented 2 years ago

Now it works, thank you very much