smarthomej / addons

SmartHome/J addons for openHAB
Eclipse Public License 2.0
59 stars 23 forks source link

tuya devices with protocoll 3.4 #466

Closed mues-lee closed 1 year ago

mues-lee commented 1 year ago

Hello,

are there any plans to support tuya devices that are using protocol 3.4?

Thanks in advance Mues

J-N-K commented 1 year ago

Unfortunately I don't have such a device. If you would be willing to test that, I could have a look and implement something.

mues-lee commented 1 year ago

that would be great and of course I'm willing to test

I currently running openHAB 3.4.2 (openHABian image on a rpi 4 8GB), but i could also setup a 4.0 snapshot environment, in case needed

here are some information that might help in the process. The device is a G9 lightbulb (Product Category dsd)

The auto discovery generated this thing `UID: tuya:tuyaDevice:bf362468f60f0aaXXXXXXX label: G9 rechts thingTypeUID: tuya:tuyaDevice configuration: pollingInterval: 0 protocol: "3.3" productId: w0mjenqax5kgditz deviceId: bf362468f60f0aaXXXXXXX ip: 192.168.21.232 localKey: 7176f9fb0XXXXXXX channels:

with tuya-cli i could connect and read the current state admin@raspberrypi:~ $ DEBUG=* tuya-cli get --ip 192.168.21.232 --id bf362468f60f0aaXXXXXXX --key 7176f9fb0XXXXXXX --protocol-version 3.4 TuyAPI IP and ID are already both resolved. +0ms TuyAPI Connecting to 192.168.21.232... +17ms TuyAPI Socket connected. +29ms TuyAPI Protocol 3.4: Negotiate Session Key - Send Msg 0x03 +10ms TuyAPI Received data: 000055aa0000f534000000040000006800000000142be03ea30e2edb1ada0513f1556a135ada8992baf3da781a3b04decb16ddc39248d9567d4a3dc0b503872bd7953c83a66dc12e2c4b1c97495f8b6353ebb99316f1a933c8e3a6a6872e9327f219dab601452718984084c24f57594ba975f4290000aa55 +408ms TuyAPI Parsed: +9ms TuyAPI { TuyAPI payload: <Buffer 34 35 39 66 30 32 64 64 63 31 32 35 62 31 66 35 9d 7b 58 81 02 6d ff 03 bc 00 54 c3 34 84 52 f4 8c 93 c4 26 20 39 7e 25 f1 cf a0 d1 71 d5 5d 84>, TuyAPI leftover: false, TuyAPI commandByte: 4, TuyAPI sequenceN: 62772 TuyAPI } +0ms TuyAPI Protocol 3.4: Local Random Key: 589b677cbcb84e233e9af49d8762e66a +21ms TuyAPI Protocol 3.4: Remote Random Key: 34353966303264646331323562316635 +0ms TuyAPI Protocol 3.4: Session Key: 0b2f8080c5ee0b2a137089587ea18849 +3ms TuyAPI Protocol 3.4: Initialization done +1ms TuyAPI GET Payload: +7ms TuyAPI { TuyAPI gwId: 'bf362468f60f0aaXXXXXXX', TuyAPI devId: 'bf362468f60f0aaXXXXXXX', TuyAPI t: '1677859376', TuyAPI dps: {}, TuyAPI uid: 'bf362468f60f0aaXXXXXXX' TuyAPI } +0ms TuyAPI Received data: 000055aa0000f535000000100000009800000000ae3855112367fbd018355ef52d3c4bb7b248c9a985b7b9ede9bb7c2056a6f856065f46961cf7358ced4557861bba6bd43bbdf26be0c891386f732cc4f9a52ceba461d5127da50d5e8b684cf327f9dd7e27edbcb21a0a16734abbcd7f8e9ad009c88e3c9109671551e463771e07f1511525e8bd8114cda1b9ab52765b622463493e85a72c5901ba21a21f6a447fa4c9b20000aa55 +181ms TuyAPI Parsed: +2ms TuyAPI { TuyAPI payload: { TuyAPI dps: { TuyAPI '20': false, TuyAPI '21': 'white', TuyAPI '22': 1000, TuyAPI '23': 622, TuyAPI '25': '000e0d0000000000000000c80000', TuyAPI '26': 0, TuyAPI '34': false TuyAPI } TuyAPI }, TuyAPI leftover: false, TuyAPI commandByte: 16, TuyAPI sequenceN: 62773 TuyAPI } +1ms TuyAPI Received DATA packet +4ms TuyAPI data: 16 : {"dps":{"20":false,"21":"white","22":1000,"23":622,"25":"000e0d0000000000000000c80000","26":0,"34":false}} +1ms TuyAPI Pinging 192.168.21.232 +10s TuyAPI Received data: 000055aa0000f5360000000900000028000000003ccd0282e7610a36f1c1b9e6deb6f8d8fbf94d34f2cef5d10cfc507e036d567b0000aa55 +85ms TuyAPI Parsed: +2ms TuyAPI { payload: false, leftover: false, commandByte: 9, sequenceN: 62774 } +1ms TuyAPI Pong from 192.168.21.232 +2ms

J-N-K commented 1 year ago

Are you using openHAB 3.4 or 4.0?

mues-lee commented 1 year ago

Are you using openHAB 3.4 or 4.0?

As mentioned in the reply before, I currently running openHAB 3.4.2 (openHABian image on a rpi 4 8GB), but i could also setup a 4.0 snapshot environment, in case needed

J-N-K commented 1 year ago

Please change the URL in the add-service to

https://download.smarthomej.org/addons.json|https://download.smarthomej.org/addons-beta.json

uninstall the "SmartHome/J Tuya Binding" and install "SmartHome/J Tuya Binding (Develop)". Your 3.4 devices should be supported.

mues-lee commented 1 year ago

Perfect, it is working, thank you so much

The auto discovery still puts protocol 3.3 into the thing configuration, but from my side this doesn't matter because I am able to control the light bulb

timo12357 commented 1 year ago

Seems to work partially with my setup. OpenHAB 3.4 + zigbee gateway accessed with tuya-cli and scripts

5 out of 9 tuya temperature sensors behind Zigbee gateway are online, 4 remain offline 2 out of 2 tuya bulbs with protocol version 3.4 are online

J-N-K commented 1 year ago

But the ZigBee sensors are not connected via the Tuya binding, correct?

timo12357 commented 1 year ago

Correct. I call them with tuya-cli. 5 of them are online via the Tuya binding, too. Edit: I get everything working when I use the Tuya binding ONLY for the protocol version 3.4 bulbs. I read the temperature sensors with my script.