Koenkk / zigbee2mqtt

Zigbee 🐝 to MQTT bridge πŸŒ‰, get rid of your proprietary Zigbee bridges πŸ”¨
https://www.zigbee2mqtt.io
GNU General Public License v3.0
11.25k stars 1.6k forks source link

Support for "Parkside Smart Watering Timer" #7695

Closed DerElch87 closed 1 year ago

DerElch87 commented 2 years ago

Dear all, I tried to create support for the Parkside Smart Watering Timer, but failed catastrophically :)

I created a .js file for Tuya like explained in the tutorial - but then Z2M will not start anymore. I copied the content on the bottom of the message. If anyone is willing to help, I'd highly appreciate.

Thanks and best regards

Information about the device + link

Parkside Smart Watering Timer https://www.lidl.de/de/parkside-smarter-bewaesserungscomputer-zigbee-smart-home/p375570

Failure message when starting Z2M

[08:04:41] INFO: Handing over control to Zigbee2mqtt Core ...

zigbee2mqtt@1.19.0 start /app node index.js (node:398) UnhandledPromiseRejectionWarning: ReferenceError: tuya is not defined (Use node --trace-warnings ... to show where the warning was created) (node:398) 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:398) [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.

PSBZS.js

const fz = require('zigbee-herdsman-converters/converters/fromZigbee'); const tz = require('zigbee-herdsman-converters/converters/toZigbee'); const exposes = require('zigbee-herdsman-converters/lib/exposes'); const reporting = require('zigbee-herdsman-converters/lib/reporting'); const extend = require('zigbee-herdsman-converters/lib/extend'); const e = exposes.presets; const ea = exposes.access;_

const definition = { fingerprint: [ { modelID: 'TS0601', manufacturerName: '_TZE200_c88teujp' }, ], model: 'PSBZS A1', vendor: 'Lidl', description: 'Smart Watering Timer', supports: 'thermostat, temperature', fromZigbee: [ fz.ignore_basic_report, // Add this if you are getting no converter for 'genBasic' fz.tuya_data_point_dump, // This is a debug converter, it will be described in the next part ], toZigbee: [ tz.tuya_data_point_test, // Another debug converter ], onEvent: tuya.setTime, // Add this if you are getting no converter for 'commandSetTimeRequest' configure: async (device, coordinatorEndpoint, logger) => { const endpoint = device.getEndpoint(1); await reporting.bind(endpoint, coordinatorEndpoint, ['genBasic']); }, exposes: [ // Here you should put all functionality that your device exposes ], };

module.exports = definition;

Edit: Link to Zigbee Alliance https://zigbeealliance.org/zigbee_products/smarter-water-computer/

fluppie commented 2 years ago

I also have this module :-) https://www.lidl-shop.be/nl-BE/PARKSIDE-Besproeiingscomputer-Smart-Home-PSBZS-A1/p100325201

afbeelding

Friendly name
    0x847127fffea96df6
Device type
    EndDevice
Zigbee model
    TS0601
Support status

    Unsupported
IEEE address
    0x847127fffea96df6
Network address
    0xFDB7
Power source
    Battery 
Interview completed
    Yes
fluppie commented 2 years ago

database.db entry:

{"id":17,"type":"EndDevice","ieeeAddr":"0x847127fffea96df6","nwkAddr":64951,"manufId":4098,"manufName":"_TZE200_htnnfasr","powerSource":"Battery","modelId":"TS0601","epList":[1],"endpoints":{"1":{"profId":260,"epId":1,"devId":0,"inClusterList":[0,4,5,6,3,61184],"outClusterList":[25,10],"clusters":{"genBasic":{"attributes":{"modelId":"TS0601","manufacturerName":"_TZE200_htnnfasr","powerSource":3,"zclVersion":3,"appVersion":86,"stackVersion":0,"hwVersion":1,"dateCode":""}}},"binds":[],"configuredReportings":[],"meta":{}}},"appVersion":86,"stackVersion":0,"hwVersion":1,"dateCode":"","zclVersion":3,"interviewCompleted":true,"meta":{},"lastSeen":1622823507874}

This could be an interesting follow as well: https://github.com/dresden-elektronik/deconz-rest-plugin/issues/4958

cru8602 commented 2 years ago

I created a converter file that at least worked to switch the valve on and off:

const fz = require('zigbee-herdsman-converters/converters/fromZigbee');
const tz = require('zigbee-herdsman-converters/converters/toZigbee');
const exposes = require('zigbee-herdsman-converters/lib/exposes');
const reporting = require('zigbee-herdsman-converters/lib/reporting');
const extend = require('zigbee-herdsman-converters/lib/extend');
const e = exposes.presets;
const ea = exposes.access;

const definition = {
    zigbeeModel: ['TS0601'], // The model ID from: Device with modelID 'lumi.sens' is not supported.
    model: 'HG06875', // Vendor model number, look on the device for a model number
    vendor: 'PARKSIDE', // Vendor of the device (only used for documentation and startup logging)
    description: 'Smart Watering Timer', // Description of the device, copy from vendor site. (only used for documentation and startup logging)
    fromZigbee: [fz.on_off], // We will add this later
    toZigbee: [tz.on_off], // Should be empty, unless device can be controlled (e.g. lights, switches).
    exposes: [e.switch()], // Defines what this device exposes, used for e.g. Home Assistant discovery and in the frontend
    configure: async (device, coordinatorEndpoint, logger) => {
        const endpoint = device.getEndpoint(1);
        await reporting.bind(endpoint, coordinatorEndpoint, ['genOnOff']);
        await reporting.onOff(endpoint);
    },
};

module.exports = definition;

The valve doesn't seem to report back if it is switched or not and also it switches of autmaticly after about 60 sec. This time intervall can possibly be changed using the lidl gateway but I didn't found any messages that gave me a hint how to do this in z2m. I also tryed to integrate the battery state but this also doesn't seems to be reported.

TheOriginal92 commented 2 years ago

How did you manage to pair it? The Pressing the button for a few seconds until the left led is blinking does not seem to work for me. Im using an CC2652-P Stick.

fluppie commented 2 years ago

Short press to "activate" the module and then long press untill the red led on the left starts blinking. @cru8602 where did you store this file? Or did you add this somewhere in the web UI of Z2M?

TheOriginal92 commented 2 years ago

Short press to "activate" the module and then long press untill the red led on the left starts blinking. @cru8602 where did you store this file? Or did you add this somewhere in the web UI of Z2M?

Thank you, did just that. Left led starts blinking but nothing happening in Z2M in debug log

stefangries commented 2 years ago

Thank you, did just that. Left led starts blinking but nothing happening in Z2M in debug log

You can try to reset the device by holding the button while inserting the battery.

TheOriginal92 commented 2 years ago

Thank you, did just that. Left led starts blinking but nothing happening in Z2M in debug log

You can try to reset the device by holding the button while inserting the battery.

Thank you very much. I got it paired with another, similar CC2652p stick now. Just need to figure out why it won’t pair with the first stick.

Using above mentioned converter I m able to control the valve.

EDIT: Unplugging the stick and a reboot fixed the issue. Now on to sniffing the device communication.

cru8602 commented 2 years ago

@fluppie I named the file HG06875.js and added it to the data folder in which the configuration.yaml is located. After that I used the front-end to add "HG06875.js" in the external converters section.

Main-pinguin commented 2 years ago

Seems to be a bit more complex ... I have setup a device via Tuya gateway with some intervals. This intervals still ongoing even Tuya gateway is out of range and device is paired with my testbed based on a CC2531. The GenOn seem to have the same behaviour as the manuall watering Button on the Device... This button activate the valve even for about 60 sec. Unfortunately I didn't get the Tuya datapoint debuging eorking on my test bed... However will continue to work on

BiasF commented 2 years ago

same here, didn't get the debugging working. The valve has only one button but doesn't send any messages via zigbee while pressing the button.

Maybe thats why the datapoint debugging doesn't help....

enzzo-ux commented 2 years ago

I also have a problem with starting. Received message from unsupported device with Zigbee model 'TS0601' and manufacturer name '_TZE200_htnnfasr'

digdas1 commented 2 years ago

Hi,

I got the device myself. I do see it with deconz, and also the switching off after 60 seconds. Can I help? My setup: Conbee 2 stick, with deconz (which sees it as a light)

BiasF commented 2 years ago

I think it's not usefull to sniff traffic between Conbee and the watering timer

You have to sniff the traffic between the original LIDL Gateway and the watering timer, to see which commands the original gateway is sending to the device.

My Lidl Gateway should arrive today,

BiasF commented 2 years ago

argh, I now have a LIDL Gateway and the watering timer.... but ZSHARK doesn't work with a Conbee II, only with Conbee I -,-

I also have a "Slaesh's CC2652RB stick" but it's my production network stick and I dont want to destroy my Zigbee network with flashing this stick.

Any Ideas how to sniff with one of theese devices without destroing my Zigbee network ?

dasfuu commented 2 years ago

Only a cheap CC2531 stick comes to mind. I have a generic Tuya Gateway and Watering Timer here. Never sniffed zigbee before. I will try in the next days too.

VictorvandenHoven commented 2 years ago

@cru8602 Thanks for the converter file. At least I can use it as a switch now in Home Assistant.

fschaefer commented 2 years ago

I have setup a device via Tuya gateway I have a generic Tuya Gateway @Main-pinguin @dasfuu

Which gateways do you guys use?

Main-pinguin commented 2 years ago

I have setup a device via Tuya gateway I have a generic Tuya Gateway @Main-pinguin @dasfuu

Which gateways do you guys use?

I didn't have any of this gateways.. I tested it at riend of mine on Lidl gateway... When I visit my friend next time I will try to sniff the zigbee traffic between GW and valve ... But could't promise any timeline...

dasfuu commented 2 years ago

I have setup a device via Tuya gateway I have a generic Tuya Gateway @Main-pinguin @dasfuu

Which gateways do you guys use?

I have this one: https://www.amazon.de/gp/product/B08PF4ZYNY/ Parkside watering thing works perfectly with all features.

BiasF commented 2 years ago

Now I am able to sniff with a CC2531 between the original LIDL Gateway and the Smart Watering Timer.

Here is a example PCAP file from WireShark, if this is usefull for implementing the device in Zigbee2Mqtt I can provide more capture files for specific actions :)

LIDL-GW-Watering.txt

VentiloFred commented 2 years ago

argh, I now have a LIDL Gateway and the watering timer.... but ZSHARK doesn't work with a Conbee II, only with Conbee I -,-

I also have a "Slaesh's CC2652RB stick" but it's my production network stick and I dont want to destroy my Zigbee network with flashing this stick.

Any Ideas how to sniff with one of theese devices without destroing my Zigbee network ?

Hello, work for me with Conbee II version 2.10.04 / 14/03/2021 Firmware 26660700

Home Assistant version core-2021.6.4 deCONZ version 6.8.0

With HA i can switch On, no feedback With Node Red I can switch On / Off but automatically Off after 60s!

VentiloFred commented 2 years ago

For this moment i use this solution: I send every 10sec (for this moment) "true" with Node Red to the Parkside valve until when i want to stop the valve

image

Main-pinguin commented 2 years ago

I have as well some taces from Wireshark. As they are from an in-production network I will them not share all. As example Button pressed On_F.txt Set 10min and on via GW.txt Button pressed On_F.txt (need to be renamed- it is a wireshark file...) is the trace when button on valve is presse twice top open valve Set 10min and on via GW.txt is the trace of data exchanged between GW and valve if in application a 10 min watering time is set and the valve is activated.

MattWestb commented 2 years ago

For looking inside the data the current network key is needed or only getting "data" and no information.

BiasF commented 2 years ago

Hi,

for my testing network the key is 9e7d5dd06bd96b5479fe631cc230c9d5

MattWestb commented 2 years ago

Sorry not working ;-(((

BiasF commented 2 years ago

Did you add the TrustCenter key?

Add the Trust Center link key by going to to Edit -> Preferences -> Protocols -> ZigBee. Set Security Level to AES-128 Encryption, 32-bit Integrity Protection and click on Edit. Click on + and add 5A:69:67:42:65:65:41:6C:6C:69:61:6E:63:65:30:39 with Byte Order Normal.

MattWestb commented 2 years ago

Looks witch key its being in use in the ZigBee Security Header:

ZigBee Network Layer Command, Dst: Broadcast, Src: 0x0000
    Frame Control Field: 0x1209, Frame Type: Command, Discover Route: Suppress, Security, Extended Source Command
    Destination: 0xfffc
    Source: 0x0000
    Radius: 1
    Sequence Number: 213
    Extended Source: SiliconL_ff:fe:cc:6c:ea (58:8e:81:ff:fe:cc:6c:ea)
    ZigBee Security Header
        Security Control Field: 0x28, Key Id: Network Key, Extended Nonce
        Frame Counter: 136740
        Extended Source: SiliconL_ff:fe:cc:6c:ea (58:8e:81:ff:fe:cc:6c:ea)
        Key Sequence Number: 0
        Message Integrity Code: 0dbb429c
        [Key: -x-x-x-x-x-x]
        [Key Label: LIDL ZBGW]
    Command Frame: Link Status

Key is "patched".

I have 8 active working network keys plus the "normal master" keys in the table.

BiasF commented 2 years ago

Mhhh should be the right key

image

MattWestb commented 2 years ago

With: ZBKY01

Is getting: ZBKY02

BiasF commented 2 years ago

you opened not my pcap file ;) it's the file from Main-pinguin

MattWestb commented 2 years ago

110% true !!! :-)))

And is with one paring so the transport of the network key is inside the sniff :-))

MattWestb commented 2 years ago

Its looks like its setting up the device with one command for using tuya commands:

ZigBee Application Support Layer Data, Dst Endpt: 1, Src Endpt: 1
    Frame Control Field: Data (0x00)
    Destination Endpoint: 1
    Cluster: Basic (0x0000)
    Profile: Home Automation (0x0104)
    Source Endpoint: 1
    Counter: 1
ZigBee Cluster Library Frame, Command: Write Attributes, Seq: 1
    Frame Control Field: Profile-wide (0x10)
    Sequence Number: 1
    Command: Write Attributes (0x02)
    Attribute Field, Uint8: 13
        Attribute: Unknown (0xffde)
        Data Type: 8-Bit Unsigned Integer (0x20)
        Uint8: 13 (0x0d)

All the rest is "normal tuya commands" and no Zigbee standard commands more then the handshaking with default response for the no ZCL commands.

MattWestb commented 2 years ago

@BiasF do you have one sniff then sending one "on command" from the tuya ZBGW ? It can its only sending tuya commands and not normal zigbee "on" that we have being using but is not getting the status reported back if the device is on or off.

Main-pinguin commented 2 years ago

Its looks like its setting up the device with one command for using tuya commands:

ZigBee Application Support Layer Data, Dst Endpt: 1, Src Endpt: 1
    Frame Control Field: Data (0x00)
    Destination Endpoint: 1
    Cluster: Basic (0x0000)
    Profile: Home Automation (0x0104)
    Source Endpoint: 1
    Counter: 1
ZigBee Cluster Library Frame, Command: Write Attributes, Seq: 1
    Frame Control Field: Profile-wide (0x10)
    Sequence Number: 1
    Command: Write Attributes (0x02)
    Attribute Field, Uint8: 13
        Attribute: Unknown (0xffde)
        Data Type: 8-Bit Unsigned Integer (0x20)
        Uint8: 13 (0x0d)

All the rest is "normal tuya commands" and no Zigbee standard commands more then the handshaking with default response for the no ZCL commands.

That's even my assumption here a cut out of trace "button on valve pressed for open valve"

Frame 2: 12 bytes on wire (96 bits), 10 bytes captured (80 bits) on interface \.\pipe\zboss_sniffer_COM5, id 0 IEEE 802.15.4 Command, Dst: 0x2ebe, Src: 0x053e

No. Time Source Destination Protocol Length Info
3 8.499833 0x053e 0x0000 ZigBee HA 58 Unknown Command: 0x02, Seq: 98

Frame 3: 58 bytes on wire (464 bits), 56 bytes captured (448 bits) on interface \.\pipe\zboss_snifferCOM5, id 0 IEEE 802.15.4 Data, Dst: 0x2ebe, Src: 0x053e ZigBee Network Layer Data, Dst: 0x0000, Src: 0x053e ZigBee Application Support Layer Data, Dst Endpt: 1, Src Endpt: 1 ZigBee Cluster Library Frame Frame Control Field: Cluster-specific (0x09) Sequence Number: 98 Command: Unknown (0x02)_ Data (10 bytes)

0000 00 c7 06 02 00 04 00 00 00 3c .........< Data: 00c7060200040000003c [Length: 10]

No. Time Source Destination Protocol Length Info
4 8.600815 0x053e 0x2ebe IEEE 802.15.4 12 Data Request

Frame 4: 12 bytes on wire (96 bits), 10 bytes captured (80 bits) on interface \.\pipe\zboss_sniffer_COM5, id 0 IEEE 802.15.4 Command, Dst: 0x2ebe, Src: 0x053e

No. Time Source Destination Protocol Length Info
5 8.603538 0x0000 0x053e ZigBee HA 50 ZCL: Default Response, Seq: 98

Frame 5: 50 bytes on wire (400 bits), 48 bytes captured (384 bits) on interface \.\pipe\zboss_sniffer_COM5, id 0 IEEE 802.15.4 Data, Dst: 0x053e, Src: 0x2ebe ZigBee Network Layer Data, Dst: 0x053e, Src: 0x0000 ZigBee Application Support Layer Data, Dst Endpt: 1, Src Endpt: 1 ZigBee Cluster Library Frame, Command: Default Response, Seq: 98 Frame Control Field: Profile-wide (0x00) Sequence Number: 98 Command: Default Response (0x0b) Response to Command: 0x02 Status: Success (0x00)

BiasF commented 2 years ago

@MattWestb Here comes the TUYA_ON Sniff

TUYA_ON.txt

MattWestb commented 2 years ago

If taking all normal handshaking away and only looking of the strange data being sent is like this:

Source > Destination "tuya data" (Sequence number)
0x0000 > 0xb6c3 00b6050200040000000f0101000101 (65)
0xb6c3 > 0x0000 00b7060200040000000f (8)
0xb6c3 > 0x0000 00b80101000101050200040000000f (9)
0xb6c3 > 0x0000 00b90b0200040000005a (10)
0xb6c3 > 0x0000 00ba060200040000000e (11)

I think its "normal tuya commands" one to the device and the device is reporting back attribute changes but i think some other users can interpreting it better then i have no deep experience of tuyas protocol. The good thing is that the device is looking reporting much data back so its very likely getting real status from it :-)))

mgrom commented 2 years ago

Hey guys, I've just started decoding messages that are being send between gateway and the device. I've found that the you can switch on the device but still there is auto off defined (default 1minute) - there will be a way to change it. Please be patient :D work in progress, but looks promissing.

MattWestb commented 2 years ago

The 1 minute is one safety future and can not (very likely) being overridden. The automation is easy to making in HA only triggering one on command every 55 seconds as long the water period is active.

The the status is very interesting to getting working :-))

dasfuu commented 2 years ago

The 1 minute is one safety future and can not (very likely) being overridden.

That status can be overriden. In the SmartLife App you can specifiy that intervall/timeout. It even stays like that if you then pair it with another network.

Also you can store rules on the device to enable it on certain days and times, with a given interval, pauses and recurrence.

MattWestb commented 2 years ago

@Smanar have start diving in the tuya commands so its start moving :-)))

mgrom commented 2 years ago

@MattWestb did you manage to sniff any messages between zigbee2mqtt dongle and the device? I can sniff messages between Tuya GW and the device but the only message that the device is sending when connected to zigbee2mqtt dongle is request for local time, after that nothing...

divemasterjm commented 2 years ago

@fluppie I named the file HG06875.js and added it to the data folder in which the configuration.yaml is located. After that I used the front-end to add "HG06875.js" in the external converters section.

i tried but when z2m starts it throws an error and keeps restarting

MattWestb commented 2 years ago

The interesting is wot the tuya ZBGW is doing with the device then pairing and also then sending commands and changing the configuration like adding scheduled and extending the on time parameters.

For the moment Z2M is treating it as one "normal zigbee device" so no magic is being made. Need waiting for @Smanar and other devs is finding and can implanting it in the system for getting it working OK.

mgrom commented 2 years ago

@Koenkk sorry for disturbing :) but I have some trouble with this device. What I've done so far:

Problem: Device when linked to TGW is sending commands: image but when linked to zigbee2mqtt there is radio silence.... so there is no possible way to use tuya_data_point_dump because there are no messages.

Where to look for answers?

MattWestb commented 2 years ago

You need sending the initiating command from the sniffed https://github.com/Koenkk/zigbee2mqtt/issues/7695#issuecomment-865867667 the first command is from the coordinator to the device.

mgrom commented 2 years ago

I don't think so. First message with tuya-like data is sent by the device. The only message that is being sent before this is coordinators command: image But I've already tried to send it, and with no changes...

Smanar commented 2 years ago

You realy don't have tuya request at all ?

And the device ask for gateway node descriptor (request 188), that is not realy good, it s the way used by Xiaomi to check device compatibility, some recents devices have same reaction, like the Aqara S1. To bypass this check (the conbee have not correct stack), an user include the device on the orignal gateway, use the same MAC adress and network key on the conbee, turn off the original gateway, and turn on the conbee, like that reporting is working again. The check is only done during inclusion.

mgrom commented 2 years ago

It looks like you described (device<=>TGW): image