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

Saswell TRV SEA801-ZIGBEE support #2781

Closed m4tek closed 3 years ago

m4tek commented 4 years ago

I'm looking to get some support with adding SEA801-ZIGBEE TRV.

I managed to connect it to the network and it is reporting state changes correctly. It sends updates in with cluster '61184' and type 'raw'. Those are HEX words that I got sorted out for the most part.

I can see hvacThermostat which covers all the options that are available for this value, but my device uses raw data in this custom cluster

Issues I'm struggling right now:

Should I start with defining new cluster in ZCL? Should I do any bindings in the initial devices.js config, as there is no documentation that I was able to find that would describe this part I don't have SASWELL hub, so I cannot fully capture 2-directional communication, but I'm working in the assumption that the same binary/hex format is used in both direction

Capture data: https://docs.google.com/spreadsheets/d/1BaKJdkmumf3S8rP4JfhNATyeryAGX9wh416llWWFACQ/edit#gid=0

rotragit commented 4 years ago

I asked SASWELL for documentation, but I've got no response.

m4tek commented 4 years ago

We can get far without it, but @Koenkk or someone from the core DEV team needs to share some guidance on how to approach it. I don't want to start moving in wrong direction.

sjorge commented 4 years ago

Starting with an existing TRV is probably a good jump of point. Just stay clear of the schneider or eurotronic ones as they have a lot of custom converters

Koenkk commented 4 years ago

Raw messages is not a good sign, it means that the TRV uses some custom cluster (which you need to figure out). Does wireshark show anything interesting when sniffing? https://www.zigbee2mqtt.io/how_tos/how_to_sniff_zigbee_traffic.html

m4tek commented 4 years ago

Raw messages is not a good sign, it means that the TRV uses some custom cluster (which you need to figure out). Does wireshark show anything interesting when sniffing? https://www.zigbee2mqtt.io/how_tos/how_to_sniff_zigbee_traffic.html

@Koenkk Hey, as I mentioned in my initial post I have that one figured. Cluster ID is 61184 and I have meaning of most of the fields inside of message understood out already, as described in the sheets file linked in the first comment

Starting with an existing TRV is probably a good jump of point. Just stay clear of the schneider or eurotronic ones as they have a lot of custom converters

@sjorge First it is so nice to talk you again :D and unfortunately looking around the repository, I am afraid that this device needs something similar to eurotronic

Koenkk commented 4 years ago

@m4tek good, then the next step would be to define it here: https://github.com/Koenkk/zigbee-herdsman/blob/master/src/zcl/definition/cluster.ts

m4tek commented 4 years ago

I need to do some more research, as cluster 61184 is now defined after: https://github.com/Koenkk/zigbee-herdsman/pull/125 and syntax of the message is not exactly the same :/

Math1010 commented 4 years ago

Hi, I just received a SASWELL SEA801 (no gateway) and I cannot pair it with the cc2530 module. I press the button "+" and "Auto / manu" and the text "----" appears but no message on ZigBee2MQTT, the allow_join parameter is true. Can you explain how you did to read the raw TRV data? Thanks.

gkilcaus commented 4 years ago

Hi, I just received a SASWELL SEA801 (no gateway) and I cannot pair it with the cc2530 module. I press the button "+" and "Auto / manu" and the text "----" appears but no message on ZigBee2MQTT, the allow_join parameter is true. Can you explain how you did to read the raw TRV data? Thanks.

I have the same result with cc2531

@m4tek, did you progress with integration?

rotragit commented 4 years ago

You have first to check: 1) that you have the zigbee version. It should be written on the valve "SEA801-zigbee". If you find "SEA801-APP" or other, it's not zigbee. 2) that valve has horrible wireless range. Make tests just 1 or 2 meters away from the dongle. Less is better.

romano

gkilcaus commented 4 years ago

You have first to check: 1) that you have the zigbee version. It should be written on the valve "SEA801-zigbee". If you find "SEA801-APP" or other, it's not zigbee. 2) that valve has horrible wireless range. Make tests just 1 or 2 meters away from the dongle. Less is better. romano On Tue, Feb 4, 2020 at 10:45 AM Giedrius Kilčauskas < @.***> wrote: Hi, I just received a SASWELL SEA801 (no gateway) and I cannot pair it with the cc2530 module. I press the button "+" and "Auto / manu" and the text "----" appears but no message on ZigBee2MQTT, the allow_join parameter is true. Can you explain how you did to read the raw TRV data? Thanks. I have the same result with cc2531 @m4tek https://github.com/m4tek, did you progress with integration? — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub <#2781?email_source=notifications&email_token=AFSG4VWPE37JA5UE4G6MZETRBE2LVA5CNFSM4KI2C632YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEKW7DFI#issuecomment-581824917>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFSG4VXUYR7YDOKQY2ENYLTRBE2LVANCNFSM4KI2C63Q .

Makes sense. I didn't pay attention to this when ordering. In product page it said sea801-app and on device itself it's sea801-df1. So I guess I can trash it..

rotragit commented 4 years ago

sea801-app use 868Mhz. I think sea801-df1 is just another name for the 868Mhz version. You have to buy a gateway to use them. Tuya protocol is based on MQTT (gateway to cloud server), so it could be possible to integrate at that level. I don't know. Anyway, as far as I can see, SASWELL has only implemented the zigbee protocol as an envelope around their own protocol on the sea801-zigbee version. If you look for any TRV I think it's better to look for something other and already tested. I have 5 sea801-zigbee but I'm unable to use them anyway :-(

Math1010 commented 4 years ago

Actually I have a df1 model :( Anyone have tried to disassembly the device ? Thank.

rotragit commented 4 years ago

No at the moment, but I plan to do that if I cannot return my to AliExpress. Anyway DF1 is not zigbee and the RF chip is different. One is 868Mhz, zigbee is 2,4Ghz...

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

rotragit commented 4 years ago

Ping OK, I have 5 TRV devices of this kind, but very little time to investigate, and at the moment I'm missing a CC2531 dongle with zigbee2mqtt firmware. At the moment I have sniffed the traffic when the TRV is paired within deconz (but it's not functional), and I'm comparing with the captured data by @m4tek . I confirm the layout and semantic of data. I'm not sure if the type messages are the same to send commands from zigbee2mqtt to the TRV.

Damme commented 4 years ago

Saswell messaged me the other day with a new model, SEA802-Zigbee, and they claim it talks zigbee to base station, I asked for price, resonable 15USD each + the not so resonable double for shipping.

I asked for protocol but only got specs. I'll try to convince them to release protocol since they claim it to be open protocol.

rotragit commented 4 years ago

The protocol is "open" in the sense that zigbee is open che they use the "Tuya protocol" that it's also "open". As far as I have understood, the Tuya protocol is based on a mqtt cloud server. Tuya claims to be a easy protocol to be implemented. The problem that it's like a envelope, and I haven't found anywere the description of the mqtt messages the Tuya gateway send to set the parameters on each SEA801-Zigbee (hoping the SEA801-Zigbee uses the same message types). Because I have five of them, it's possible I'll get a Tuya gateway just to sniff and learn the messages exchanged between the TRV and the gateway.

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

tsiura commented 4 years ago

I have same TRV devices. They successfully connected to the network but i cant manage them. I tied to add device to devices.js like this { zigbeeModel: ['GbxAXL2'], model: 'SEA801', vendor: 'SASWELL', description: 'SASWELL _TYST11_KGbxAXL2', supports: 'temperature', fromZigbee: [fz.tuya_thermostat_on_set_data], toZigbee: [], },

and there is some logs from z2m https://pastebin.com/FdHXHLUa

Maybe it helps )

rotragit commented 4 years ago

I should receive a Tuya Zigbee Gateway in a few days, If it works with this device I can sniff the traffic.

rotragit commented 4 years ago

Here are some sniffing (pairing, temperature set, auto/manu, on/off). I have not a zigbee2mqtt installation at the moment. I have to search where are my spare cc2531 dongles ;-)

SEA801.zip

rotragit commented 4 years ago

@Koenkk @m4tek it's possible to reopen this issue as we have a sniffed traffic to investigate?

wizardnl commented 4 years ago

just wondering if there was any update also have the same device

rotragit commented 4 years ago

it has been implemented in deconz, so we have now all the codes to port it. I can try to do that but I have to find my dongles and setup a test environment :-)

rotragit commented 4 years ago

I'm going to implement this device. I'm created the entry in devices.js and looking in fromZigbee.js where there is

const tuyaThermostat = (model, msg, publish, options, meta)

I see that model is never used and the switch case on dp is quite difficult to distinguish which dp is about which device. Many dp are common, but other are not and because the tuya protocol implements manufacturer functions among standard and cloud functions, we should expect that the same dp could have different meaning on different devices (also if all of them are TRV).I don't know what is worse or better: duplicate the function for every device, leave as it is (with no worry if a dp is about a device or another) or translate in a difficult to read if/else (because switch/case doesn't work on two variables model and dp).

Just for example, SEA801-ZIGBEE uses dp=364 instead of dp=372 for auto/manual mode. Lowbattery status id dp=1385.

m4tek commented 4 years ago

Looking at the situation, I'm in favour of duplicating functions. Trying make it work all the time will be very hard. With practical lack of unit testing it would be easy to break and hard to troubleshoot, while non obvious change in one place could have effect on the other. This is where Tuya brought us :/

miecio45 commented 3 years ago

Hello! Can I somehow help you in implementing support for Tuya thermostat valve?

Sthopeless commented 3 years ago

I'm going to implement this device. I'm created the entry in devices.js and looking in fromZigbee.js where there is

const tuyaThermostat = (model, msg, publish, options, meta)

I see that model is never used and the switch case on dp is quite difficult to distinguish which dp is about which device. Many dp are common, but other are not and because the tuya protocol implements manufacturer functions among standard and cloud functions, we should expect that the same dp could have different meaning on different devices (also if all of them are TRV).I don't know what is worse or better: duplicate the function for every device, leave as it is (with no worry if a dp is about a device or another) or translate in a difficult to read if/else (because switch/case doesn't work on two variables model and dp).

Just for example, SEA801-ZIGBEE uses dp=364 instead of dp=372 for auto/manual mode. Lowbattery status id dp=1385.

I have you successfully implemented it?

I have received mine today. from database.db:

{"id":44,"type":"EndDevice","ieeeAddr":"0xec1bbdfffe5b835b","nwkAddr":27171,"manufId":0,"manufName":"_TYST11_KGbxAXL2","powerSource":"Battery","modelId":"GbxAXL2\u0000","epList":[1],"endpoints":{"1":{"profId":260,"epId":1,"devId":0,"inClusterList":[0,3],"outClusterList":[3,25],"clusters":{"genBasic":{"attributes":{"modelId":"GbxAXL2\u0000","manufacturerName":"_TYST11_KGbxAXL2","powerSource":3,"zclVersion":3,"appVersion":73,"stackVersion":0,"hwVersion":1,"dateCode":"20180727"}}},"binds":[],"meta":{}}},"appVersion":73,"stackVersion":0,"hwVersion":1,"dateCode":"20180727","zclVersion":3,"interviewCompleted":true,"meta":{},"lastSeen":1601149622346}

I have added to my device.js:

    {
        zigbeeModel: ['GbxAXL2'],
        fingerprint: [{modelID: 'GbxAXL2\u0000', manufacturerName: '_TYST11_KGbxAXL2'}],
        model: 'GbxAXL2',
        vendor: 'TuYa',
        description: 'Saswell TRV',
        supports: 'temperature, heating system control',
        fromZigbee: [
            fz.tuya_thermostat,
            fz.tuya_water_leak,
            fz.ignore_basic_report,
        ],
        toZigbee: [
            tz.tuya_thermostat_min_temp,
            tz.tuya_thermostat_max_temp,
        ],

    },

And this is my log after pairing:

Zigbee2MQTT:debug 2020-09-26 22:51:02: Device '0xec1bbdfffe5b835b' announced itself
Zigbee2MQTT:info  2020-09-26 22:51:02: MQTT publish: topic 'zigbee2mqtt/bridge/log', payload '{"message":"announce","meta":{"friendly_name":"0xec1bbdfffe5b835b"},"type":"device_announced"}'
Zigbee2MQTT:debug 2020-09-26 22:51:12: Received Zigbee message from '0xec1bbdfffe5b835b', type 'commandSetDataResponse', cluster 'manuSpecificTuyaDimmer', data '{"data":{"data":[1],"type":"Buffer"},"dp":357,"fn":0,"status":0,"transid":1}' from endpoint 1 with groupID 0
Zigbee2MQTT:info  2020-09-26 22:51:12: MQTT publish: topic 'zigbee2mqtt/0xec1bbdfffe5b835b', payload '{"brightness":-3,"holidays":[{"hour":0,"minute":0,"temperature":0},{"hour":0,"minute":0,"temperature":0},{"hour":0,"minute":0,"temperature":0},{"hour":0,"minute":0,"temperature":0},{"hour":0,"minute":0,"temperature":0},{"hour":0,"minute":0,"temperature":0}],"level":0,"linkquality":66,"max_temperature":205,"min_temperature":249,"water_leak":true,"workdays":[{"hour":0,"minute":0,"temperature":0},{"hour":0,"minute":0,"temperature":0},{"hour":0},{},{},{}]}'
Zigbee2MQTT:debug 2020-09-26 22:51:12: Received Zigbee message from '0xec1bbdfffe5b835b', type 'commandSetDataResponse', cluster 'manuSpecificTuyaDimmer', data '{"data":{"data":[0,0,0,233],"type":"Buffer"},"dp":614,"fn":0,"status":0,"transid":2}' from endpoint 1 with groupID 0
Zigbee2MQTT:debug 2020-09-26 22:51:12: Received Zigbee message from '0xec1bbdfffe5b835b', type 'commandSetDataResponse', cluster 'manuSpecificTuyaDimmer', data '{"data":{"data":[0,0,0,205],"type":"Buffer"},"dp":615,"fn":0,"status":0,"transid":3}' from endpoint 1 with groupID 0
Zigbee2MQTT:debug 2020-09-26 22:51:12: Received Zigbee message from '0xec1bbdfffe5b835b', type 'commandSetDataResponse', cluster 'manuSpecificTuyaDimmer', data '{"data":{"data":[0],"type":"Buffer"},"dp":1385,"fn":0,"status":0,"transid":4}' from endpoint 1 with groupID 0
Zigbee2MQTT:debug 2020-09-26 22:51:12: Received Zigbee message from '0xec1bbdfffe5b835b', type 'commandSetDataResponse', cluster 'manuSpecificTuyaDimmer', data '{"data":{"data":[0],"type":"Buffer"},"dp":362,"fn":0,"status":0,"transid":5}' from endpoint 1 with groupID 0
Zigbee2MQTT:debug 2020-09-26 22:51:12: Received Zigbee message from '0xec1bbdfffe5b835b', type 'commandSetDataResponse', cluster 'manuSpecificTuyaDimmer', data '{"data":{"data":[0],"type":"Buffer"},"dp":364,"fn":0,"status":0,"transid":7}' from endpoint 1 with groupID 0
Zigbee2MQTT:debug 2020-09-26 22:51:12: Received Zigbee message from '0xec1bbdfffe5b835b', type 'commandSetDataResponse', cluster 'manuSpecificTuyaDimmer', data '{"data":{"data":[4,0,75,0,50,0,135,0,100,0,210,0,150,0,255,0,200],"type":"Buffer"},"dp":123,"fn":0,"status":0,"transid":255}' from endpoint 1 with groupID 0
Zigbee2MQTT:debug 2020-09-26 22:51:12: Received Zigbee message from '0xec1bbdfffe5b835b', type 'commandSetDataResponse', cluster 'manuSpecificTuyaDimmer', data '{"data":{"data":[4,1,104,0,210,2,208,0,200,4,56,0,205,5,160,0,200],"type":"Buffer"},"dp":124,"fn":0,"status":1,"transid":0}' from endpoint 1 with groupID 0
Zigbee2MQTT:debug 2020-09-26 22:51:12: Received Zigbee message from '0xec1bbdfffe5b835b', type 'commandSetDataResponse', cluster 'manuSpecificTuyaDimmer', data '{"data":{"data":[4,1,104,0,210,2,208,0,200,4,56,0,205,5,160,0,200],"type":"Buffer"},"dp":125,"fn":0,"status":1,"transid":1}' from endpoint 1 with groupID 0
Zigbee2MQTT:debug 2020-09-26 22:51:12: Received Zigbee message from '0xec1bbdfffe5b835b', type 'commandSetDataResponse', cluster 'manuSpecificTuyaDimmer', data '{"data":{"data":[4,1,104,0,210,2,208,0,200,4,56,0,205,5,160,0,200],"type":"Buffer"},"dp":126,"fn":0,"status":1,"transid":2}' from endpoint 1 with groupID 0
Zigbee2MQTT:debug 2020-09-26 22:51:13: Received Zigbee message from '0xec1bbdfffe5b835b', type 'commandSetDataResponse', cluster 'manuSpecificTuyaDimmer', data '{"data":{"data":[4,1,104,0,200,1,224,0,160,4,56,0,200,5,40,0,160],"type":"Buffer"},"dp":127,"fn":0,"status":1,"transid":3}' from endpoint 1 with groupID 0
Zigbee2MQTT:debug 2020-09-26 22:51:13: Received Zigbee message from '0xec1bbdfffe5b835b', type 'commandSetDataResponse', cluster 'manuSpecificTuyaDimmer', data '{"data":{"data":[4,1,104,0,210,2,208,0,200,4,56,0,205,5,160,0,200],"type":"Buffer"},"dp":128,"fn":0,"status":1,"transid":4}' from endpoint 1 with groupID 0
Zigbee2MQTT:debug 2020-09-26 22:51:13: Received Zigbee message from '0xec1bbdfffe5b835b', type 'commandSetDataResponse', cluster 'manuSpecificTuyaDimmer', data '{"data":{"data":[4,1,104,0,200,2,208,0,200,4,56,0,205,5,160,0,200],"type":"Buffer"},"dp":129,"fn":0,"status":1,"transid":5}' from endpoint 1 with groupID 0
Zigbee2MQTT:debug 2020-09-26 22:51:13: Received Zigbee message from '0xec1bbdfffe5b835b', type 'commandSetDataResponse', cluster 'manuSpecificTuyaDimmer', data '{"data":{"data":[0,0,0,0,0,0,0,0,0,0,0,20,22,23,23,24,24,23,24,23,23,23,0,0],"type":"Buffer"},"dp":115,"fn":0,"status":0,"transid":9}' from endpoint 1 with groupID 0
Zigbee2MQTT:debug 2020-09-26 22:51:13: Received Zigbee message from '0xec1bbdfffe5b835b', type 'commandSetDataResponse', cluster 'manuSpecificTuyaDimmer', data '{"data":{"data":[0,0,0,0,0,0,0,0,0,0,0,16,16,18,17,21,9,15,20,20,20,20,0,0],"type":"Buffer"},"dp":110,"fn":0,"status":0,"transid":13}' from endpoint 1 with groupID 0
Zigbee2MQTT:debug 2020-09-26 22:51:13: Received Zigbee message from '0xec1bbdfffe5b835b', type 'commandSetDataResponse', cluster 'manuSpecificTuyaDimmer', data '{"data":{"data":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,10,17,0,0,0,0,0,0,0],"type":"Buffer"},"dp":119,"fn":0,"status":0,"transid":17}' from endpoint 1 with groupID 0
Zigbee2MQTT:debug 2020-09-26 22:51:13: Received Zigbee message from '0xec1bbdfffe5b835b', type 'commandSetDataResponse', cluster 'manuSpecificTuyaDimmer', data '{"data":{"data":[0,0,0,0,0,0,0],"type":"Buffer"},"dp":116,"fn":0,"status":0,"transid":10}' from endpoint 1 with groupID 0
Zigbee2MQTT:debug 2020-09-26 22:51:13: Received Zigbee message from '0xec1bbdfffe5b835b', type 'commandSetDataResponse', cluster 'manuSpecificTuyaDimmer', data '{"data":{"data":[0,0,0,0,0,0,0],"type":"Buffer"},"dp":112,"fn":0,"status":0,"transid":14}' from endpoint 1 with groupID 0
Zigbee2MQTT:debug 2020-09-26 22:51:13: Received Zigbee message from '0xec1bbdfffe5b835b', type 'commandSetDataResponse', cluster 'manuSpecificTuyaDimmer', data '{"data":{"data":[0,0,0,0,0,0,0],"type":"Buffer"},"dp":120,"fn":0,"status":0,"transid":18}' from endpoint 1 with groupID 0
Zigbee2MQTT:debug 2020-09-26 22:51:13: Received Zigbee message from '0xec1bbdfffe5b835b', type 'commandSetDataResponse', cluster 'manuSpecificTuyaDimmer', data '{"data":{"data":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"type":"Buffer"},"dp":117,"fn":0,"status":0,"transid":11}' from endpoint 1 with groupID 0
Zigbee2MQTT:debug 2020-09-26 22:51:13: Received Zigbee message from '0xec1bbdfffe5b835b', type 'commandSetDataResponse', cluster 'manuSpecificTuyaDimmer', data '{"data":{"data":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"type":"Buffer"},"dp":113,"fn":0,"status":0,"transid":15}' from endpoint 1 with groupID 0
Zigbee2MQTT:debug 2020-09-26 22:51:14: Received Zigbee message from '0xec1bbdfffe5b835b', type 'commandSetDataResponse', cluster 'manuSpecificTuyaDimmer', data '{"data":{"data":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"type":"Buffer"},"dp":121,"fn":0,"status":0,"transid":19}' from endpoint 1 with groupID 0
Zigbee2MQTT:debug 2020-09-26 22:51:14: Received Zigbee message from '0xec1bbdfffe5b835b', type 'commandSetDataResponse', cluster 'manuSpecificTuyaDimmer', data '{"data":{"data":[0,0,0,0,0,0,0,0,0,0,0,0],"type":"Buffer"},"dp":118,"fn":0,"status":0,"transid":12}' from endpoint 1 with groupID 0
Zigbee2MQTT:debug 2020-09-26 22:51:14: Received Zigbee message from '0xec1bbdfffe5b835b', type 'commandSetDataResponse', cluster 'manuSpecificTuyaDimmer', data '{"data":{"data":[0,0,0,0,0,0,0,0,0,0,0,0],"type":"Buffer"},"dp":114,"fn":0,"status":0,"transid":16}' from endpoint 1 with groupID 0
Zigbee2MQTT:debug 2020-09-26 22:51:14: Received Zigbee message from '0xec1bbdfffe5b835b', type 'commandSetDataResponse', cluster 'manuSpecificTuyaDimmer', data '{"data":{"data":[0,0,0,0,0,0,0,0,0,0,0,0],"type":"Buffer"},"dp":122,"fn":0,"status":0,"transid":20}' from endpoint 1 with groupID 0

"max_temperature":205 is the target temp I have set on the TRV "min_temperature":249 I'm assuming is the current temp

I have also connected the TRV to wireshark and my findings can be seen here on Google Sheet Link TLDR

I'm still struggling to understand how to add it correctly to Z2M so any help would be extremely appreciated.

skumka commented 3 years ago

I am struggling with SEA802... I am new to all z2m concept and getting crazy. I would love to help but I need to know what I should do. Actually I have found similar topic with more details on similar problem. https://community.home-assistant.io/t/i-am-totally-noob-with-zigbee-and-tuya-and-i-need-advice-for-smart-thermostatic-radiator-valves/163607/21

It ended up with pull request.

rotragit commented 3 years ago

I'm sorry, I have very little time in this period of the year. This is tuya explained: https://medium.com/@dzegarra/zigbee2mqtt-how-to-add-support-for-a-new-tuya-based-device-part-2-5492707e882d This tuya documentation, where we find each tuya device (could) have custom functions: https://docs.tuya.com/en/iot/configure-in-platform/function-definition/define-product-features?id=K97vug7wgxpoq Here is the deconz issue about this TRV: https://github.com/dresden-elektronik/deconz-rest-plugin/issues/3109#issuecomment-678367184 Here is the deconz code implementing this TRV (look for GbxAXL2): https://github.com/Smanar/deconz-rest-plugin/blob/master/tuya.cpp

insipiens commented 3 years ago

I now have 2 of these. i see a lot of the hard work has already been done!

I like that they have metal cups to screw to the valve body, some others like moes hy368 are all plastic and can break.

Will be good to have these in Z2M

Sthopeless commented 3 years ago

glad you are on board @insipiens I tried looking at the deconz implementation but it's all gibberish to me 😞. And my 'achievements' are documented on my post above. I hope it helps

skumka commented 3 years ago

@Sthopeless +1 @insipiens I have SEA802. Please let me know if I can help you with testing this one too. Maybe implementation can cover both.

insipiens commented 3 years ago

@skumka @Sthopeless Thanks for the welcome.....

I have a few days off next week so I should be able to work on this.

If it follows the usual Tuya format, which the Deconz work shows, even with different codes it should be straightforward........... Famous last words, right!

insipiens commented 3 years ago

I made a start:

MQTT publish: topic 'zigbee2mqtt/Saswell TRV', payload '{"current_heating_setpoint":"15.5","linkquality":52,"local_temperature":"16.4","preset_mode":"manual","system_mode":"heat"}'

Mainly just reading from the device, but have added adjusting the set temperature

image

image

rotragit commented 3 years ago

Great!

skumka commented 3 years ago

Great! Would you mind sharing what is your definition from Devices.js?

insipiens commented 3 years ago

These are the additions I have made so far, make a back up of each file and use at own risk.

line numbers are indicative only

//Device.js

    {
        fingerprint: [{modelID: 'GbxAXL2\u0000', manufacturerName: '_TYST11_KGbxAXL2'}],
        model: 'GbxAXL2',
        vendor: 'Saswell',
        description: 'Saswell Thermostatic Radiator Valve',
        supports: 'thermostat, temperature',
        fromZigbee: [fz.saswell_thermostat],
        toZigbee: [tz.saswell_thermostat_current_heating_setpoint],
        meta: {configureKey: 1},    
        configure: async (device, coordinatorEndpoint) => {
            const endpoint = device.getEndpoint(1);
            await bind(endpoint, coordinatorEndpoint, ['genBasic']);
        },  
    },

//homeassistant.js

    'GbxAXL2': [
        climate(5, 30, 'current_heating_setpoint', 0.5, ['off', 'heat'], [], ['manual', 'program']),
    ],

//fromZigbee.js

//inserted after Tuya thermostat at line 465

const saswellThermostat = (model, msg, publish, options, meta) => {
    const dp = msg.data.dp;
    const data = msg.data.data;
    const dataAsDecNumber = utils.convertMultiByteNumberPayloadToSingleDecimalNumber(data)
    let temperature;

    switch (dp) {
    case 357: // Thermostat on off  = off, on = heat
        return {system_mode: dataAsDecNumber ? 'heat' : 'off'};
    case 362: // away mode
    return {preset_mode: dataAsDecNumber ? 'away' : 'auto'};     
    case 364: // Changed program mode 
        return {preset_mode: dataAsDecNumber ? 'auto' : 'manual'};   
    case 614: // MCU reporting room temperature
        temperature = (dataAsDecNumber / 10).toFixed(1);
        return {local_temperature: temperature};
    case 615: // set temperature
        temperature = (dataAsDecNumber / 10).toFixed(1);
        return {current_heating_setpoint: temperature};
    default:
        meta.logger.warn(`zigbee-herdsman-converters:SaswellThermostat: NOT RECOGNIZED DP #${
            dp} with data ${JSON.stringify(data)}`);
    }
};

//and down at around line 5595

    saswell_thermostat: {
        cluster: 'manuSpecificTuyaDimmer',
        type: ['commandGetData', 'commandSetDataResponse'],
        convert: saswellThermostat,
    },

//toZigbee.js line 3060


    saswell_thermostat_current_heating_setpoint: {
        key: ['current_heating_setpoint'],
        convertSet: async (entity, key, value, meta) => {
            const temp = Math.round(value * 10);
            const payloadValue = utils.convertDecimalValueTo2ByteHexArray(temp);
            await sendTuyaCommand(entity, 615, 0, [4, 0, 0, ...payloadValue]);
        },
    },
Sthopeless commented 3 years ago

@insipiens thanks and great job! Btw what are your thoughts this vs the Moes TRV's? design aside

insipiens commented 3 years ago

These are DP codes I haven't figured out yet which are coming from the device.

112 113 114 116 117 118 120 121 122

115

110 119

I've analysed the program DPs that are sent:

123 124 125 126 127 128 129

each one is for a day's program 1-7 divided into 4 sections as indicated by the first values 4, and the time is calculated from the 2nd, 3rd, then 6th & 7th etc. using a formula: int(a*256+b)/60 for hour and mod 60 for minutes (I think)

example:

[4,1,14,0,155,1,224,0,150,4,56,0,150,5,40,0,160]}

1*256+14 = 04:30am

insipiens commented 3 years ago

Ah, how embarrassing, noticed an error :/

homeassistant.js should be manual or auto, not manual or program

    'GbxAXL2': [
        climate(5, 30, 'current_heating_setpoint', 0.5, ['off', 'heat'], [], ['manual', 'auto']),
    ],  //saswell

Some additional 'toZigbee.js' clauses - to control system mode (off/on) and preset manual/auto from home assistant or other HA - just add them on to the end of the earlier clauses.

    saswell_thermostat_mode: {
        key: ['preset'],
        convertSet: async (entity, key, value, meta) => {
            if( value == 'auto'){ sendTuyaCommand(entity, 364, 0, [1, 1]) }
            else { sendTuyaCommand(entity, 364, 0, [1, 0]) }
        },
    },
    saswell_thermostat_standby: {
        key: ['system_mode'],
        convertSet: async (entity, key, value, meta) => {
            sendTuyaCommand(entity, 357, 0, [1, value === 'heat' ? 1 : 0]);
        },
    },

and the replacement "device.js" entry to include those changes:

    {
        fingerprint: [{modelID: 'GbxAXL2\u0000', manufacturerName: '_TYST11_KGbxAXL2'}],
        model: 'GbxAXL2',
        vendor: 'Saswell',
        description: 'Saswell Thermostatic Radiator Valve',
        supports: 'thermostat, temperature',
        fromZigbee: [fz.saswell_thermostat],
        toZigbee: [tz.saswell_thermostat_current_heating_setpoint, tz.saswell_thermostat_mode, tz.saswell_thermostat_standby],
        meta: {configureKey: 1},    
        configure: async (device, coordinatorEndpoint) => {
            const endpoint = device.getEndpoint(1);
            await bind(endpoint, coordinatorEndpoint, ['genBasic']);
        },  
    },
insipiens commented 3 years ago

We will need to clarify the missing fromZigbee.js DP codes before we can PR this.

How far do we want to go with the toZigbee.js commands?

rotragit commented 3 years ago

in deconz we didn't solve all the codes. I had the tuya gateway for a while and I was unable to understand the meaning.

On Fri, Oct 9, 2020 at 9:15 PM insipiens notifications@github.com wrote:

We will need to clarify the missing fromZigbee.js DP codes before we can PR this.

How far do we want to go with the toZigbee.js commands?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/Koenkk/zigbee2mqtt/issues/2781#issuecomment-706358458, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFSG4VR3N2VK5G2ZH7KZHRLSJ5OMVANCNFSM4KI2C63Q .

insipiens commented 3 years ago

I'll take a look sometime this weekend. Would be great for some feedback on functionality etc.

insipiens commented 3 years ago

@Sthopeless

@insipiens thanks and great job! Btw what are your thoughts this vs the Moes TRV's? design aside

There are some pros and cons, the Moes HY368 has more functionality perhaps but construction seems weaker. I had one Moes break - Wife came downstairs to find it, its plastic fixing nut and a lug scattered across the hallway - to be fair Moes refunded me.

also the Z2M conversion used is shared with a few other valve models so the look in home assistant isn't as pleasing - doesn't follow the HA requirements...could this be changed? probably but you would need people testing all the related valve models...

Moes:

Of course if I come downstairs tomorrow and find the Saswell has been pebble dashing my hallway I might have a different opinion...

How the two look side by side in HA:

image

skumka commented 3 years ago

@insipiens This is great! thanks a lot. I confirm it works also for model SEA802: zigbeeModel: ['88teujp', '88teujp\u0000'], fingerprint: [{ modelID: '88teujp\u0000', manufacturerName: '_TYST11_c88teujp' }],

I think that in addtion to what is possible right now the solid baseline for those TRVs will be also:

Secondary (at least for me) are:

insipiens commented 3 years ago

10/10/2020 10:54 | #115 | {"type":"Buffer","data":[0,0,0,0,0,0,0,0,0,17,16,17,17,16,15,15,15,14,16,15,14,14,13,0]}
-- | -- | --
10/10/2020 10:54 | #110 | {"type":"Buffer","data":[0,0,0,0,0,0,0,0,0,16,17,17,17,16,15,14,14,14,14,14,14,14,17,0]}
10/10/2020 10:54 | #119 | {"type":"Buffer","data":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,35,100,10,44,85,98,100,0]}
10/10/2020 11:54 | #115 | {"type":"Buffer","data":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}
10/10/2020 11:54 | #110 | {"type":"Buffer","data":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}
10/10/2020 11:54 | #119 | {"type":"Buffer","data":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}
10/10/2020 11:54 | #116 | {"type":"Buffer","data":[0,0,0,0,9,0,0]}
10/10/2020 11:54 | #112 | {"type":"Buffer","data":[0,0,0,0,9,0,0]}
10/10/2020 11:54 | #120 | {"type":"Buffer","data":[0,0,0,0,24,0,0]}
10/10/2020 11:54 | #117 | {"type":"Buffer","data":[0,9,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}
10/10/2020 11:54 | #113 | {"type":"Buffer","data":[0,9,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}
10/10/2020 11:54 | #121 | {"type":"Buffer","data":[0,24,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}
10/10/2020 12:54 | #115 | {"type":"Buffer","data":[13,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}
10/10/2020 12:54 | #110 | {"type":"Buffer","data":[18,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}
10/10/2020 12:54 | #119 | {"type":"Buffer","data":[100,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}
10/10/2020 13:54 | #115 | {"type":"Buffer","data":[13,13,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}
10/10/2020 13:54 | #110 | {"type":"Buffer","data":[18,18,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}
10/10/2020 13:54 | #119 | {"type":"Buffer","data":[100,100,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}

I left a terminal Grepping on DP overnight and this morning to see what was produced.

Every hour these DPs are sent by the device. It looks like a history of settings, and I'm assuming the following meaning of some:

Seems the other DP codes are related to these as they start populating when the above codes are reset back to zero.

Maybe someone with a Tuya hub can see if these have some use in the App?

Sthopeless commented 3 years ago

@insipiens the app is very simple and doesn't have a lot of options.
I have this messages saved from old sniffs and I don't know what were my settings at the time.

115

00 09 73 00 00 18 17 18 18 18 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

110

00 0d 6e 00 00 18 15 14 14 14 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 

119

00 11 77 00 00 18 0d 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
insipiens commented 3 years ago

@insipiens the app is very simple and doesn't have a lot of options. I have this messages saved from old sniffs and I don't know what were my settings at the time.

115

00 09 73 00 00 18 17 18 18 18 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

110

00 0d 6e 00 00 18 15 14 14 14 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 

119

00 11 77 00 00 18 0d 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

I logged into the app last night, it only does history (what you posted above), programming, away, and off/on

Which makes me think this device is pretty much done now.