smarthomej / addons

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

[TUYA] - how to add - how to use autodiscover? #437

Closed ansorg closed 1 year ago

ansorg commented 1 year ago

hi,

I got a Tuya Outdoor smaprt plug, Model PE-01E. It's connected with tuya app on android device where I can see the plug status and power data.

I have installed the tuya binding in OpenHab 3.3.0 I have enabled the tuya logging in karaf I get messages logged like

2023-01-02 07:49:58.088 [TRACE] [.internal.local.handlers.TuyaDecoder] - udpListener: Received encoded 'very-long-string'
2023-01-02 07:49:58.089 [TRACE] [.internal.local.handlers.TuyaDecoder] - udpListener/: Decoded raw payload: {"ip":"192.168.178.xxx","gwId":"some-id","active":2,"ablilty":0,"encrypt":true,"productKey":"some-key","version":"3.3"}
2023-01-02 07:49:58.090 [DEBUG] [.internal.local.handlers.TuyaDecoder] - udpListener/: Received MessageWrapper{commandType=UDP_NEW, content='DiscoveryMessage{ip='192.168.178.xxx', deviceId='some-id', active=2, ability=0, mode=0, encrypt=true, productKey='some-key', version='3.3'}'}

Looks like the device is discovered?

Though I find no new thing in openhab.

So I tried to add a new thing manually. Used the IP and deviceid from above logs. But what is productId and localKey? I tried with gwid and productkey but this gives me CONFIGURATION_ERROR

Any hints please?

J-N-K commented 1 year ago

Did you add the device to your cloud project? The localKey is a cryptographic key that is used to communicate with the device. You can get it from the device information in the cloud project, but on the other hand: if the device is available in the cloud project, then the binding should get the key automatically.

ansorg commented 1 year ago

thanks but I have no cloud project. I wanted to avoid Cloud. I have connected the device with the android phone locally only. At least that was m assumption since I had not provided any personal details. But I just realized that there must be some cloud stuff going on because I do get data while being out of the house today?

So I need to set up this cloud account and then use that cloud to get the details for the openhab local connection? Right?

I had ignored that part in the documentation so far hoping for a local-only solution

J-N-K commented 1 year ago

You can disable the cloud (and even block access in your firewall) after the discovery is done. We only use the cloud to setup the device and get the necessary key.

With older Android devices (and App version) I believe you can also get the key by using a proxy, but I can‘t help with that, I don‘t own such a device.

ansorg commented 1 year ago

So I got it working through the cloud stuff. Thanks for making all of this even work!

I'm getting the data into OpenHab now (influxDB). But for one property of the plug add_ele I got two readings and then nothing while all the other properties continue to give data. I checked the device on the cloud portal and there is data for this property.

What could I do tho debug this?

J-N-K commented 1 year ago

What the of property is that? And what DP?

ansorg commented 1 year ago

in ohab I see tuya:tuyaDevice:bf6ced9946367cb8eai5ms:add_ele (Number) DP is 17

ansorg commented 1 year ago

additional info: checking the device in the tuya cloud I see that this specific property/item/channel gets updated only once every 30 minutes.

How is the openhap plugin actually working? Pull from the device or getting data pushed? if "pull" could it be that there is just no data unless that exact moment where 30 minutes have passed?

timo12357 commented 1 year ago

thanks but I have no cloud project. I wanted to avoid Cloud. I have connected the device with the android phone locally only. At least that was m assumption since I had not provided any personal details. But I just realized that there must be some cloud stuff going on because I do get data while being out of the house today?

So I need to set up this cloud account and then use that cloud to get the details for the openhab local connection? Right?

I had ignored that part in the documentation so far hoping for a local-only solution

Where can the documentation be found?

ansorg commented 1 year ago

Where can the documentation be found?

https://github.com/smarthomej/addons/tree/3.2.x/bundles/org.smarthomej.binding.tuya#readme

stale[bot] commented 1 year 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.