Smarthome/J Tuya Binding for openHAB 4

Hello everybody,

i can’t get the binding to discover my Pool HeatPump.
Everything seems to be set up. The cloud is online. API Authorizations should be ok. The HEATPUMP does not show up in discovery.

If i set LOG to DEBUG I get the following every 5 seconds:

[DEBUG] [.internal.local.handlers.TuyaDecoder] - udpListener: Received MessageWrapper{commandType=BROADCAST_LPV34, content='DiscoveryMessage{ip='192.168.100.119', deviceId='bfa6b9267dc1d5562anlkg', active=2, ability=0, mode=0, encrypt=true, productKey='abb8kaxcphfzkwsg', version='3.4', token= true, wf_cfg=true}'}

In TRACE Mode it shows some wired Error when starting discovery using UI:

2024-08-28 16:45:06.651 [TRACE] [ding.tuya.internal.cloud.TuyaOpenAPI] - Sending to 'https://openapi.tuyaeu.com/v1.0/users/eu1724765998599WwnVh/devices?from=&page_no=1&page_size=100': Method = {GET}, Headers = {Accept-Encoding: gzip, User-Agent: Jetty/9.4.54.v20240208, Signature-Headers: client_id, t: 1724856306650, client_id: dxkwxfg4vqrsps5h7g5j, sign: CC1419959B27265510A91B65AA62096C9B1EF8F0C3AB6E02E8795C9E3C71297C, access_token: 0dca559f7c6922696368ffd784120ba3, sign_method: HMAC-SHA256}, Content = {null}
2024-08-28 16:45:06.885 [TRACE] [a.internal.cloud.TuyaContentListener] - Received from 'https://openapi.tuyaeu.com/v1.0/users/eu1724765998599WwnVh/devices?from=&page_no=1&page_size=100': Code = {200}, Headers = {Content-Type: application/json;charset=UTF-8, Content-Length: 754, Connection: keep-alive, Date: Wed, 28 Aug 2024 14:45:06 GMT, Access-Control-Allow-Credentials: true, Access-Control-Allow-Headers: , Access-Control-Allow-Headers: access_token,Content-Type, Access-Control-Allow-Methods: POST, Access-Control-Allow-Methods: OPTIONS, Access-Control-Allow-Methods: GET, Access-Control-Allow-Methods: DELETE, Access-Control-Allow-Methods: PUT, Access-Control-Allow-Origin: https://iot.tuya.com,https://platform.tuya.com, Gateway-Info: highway, Server: Sec, Strict-Transport-Security: max-age=31536000}, Content = {{"result":[{"active_time":1724766112,"biz_type":0,"category":"znrb","create_time":1724766112,"icon":"smart/icon/bay1637720139432gd6R/835c8f12f579e6ac1bd0acc170824cd5.png","id":"bfa6b9267dc1d5562anlkg","ip":"217.142.18.121","lat":"49.2416","local_key":"7hu\u003er[.Uv-qvFeH[","lon":"12.6869","model":"","name":"WP Pool","online":true,"owner_id":"202742480","product_id":"abb8kaxcphfzkwsg","product_name":"Heat Pump","status":[{"code":"switch","value":true},{"code":"temp_set","value":320},{"code":"temp_current","value":256},{"code":"work_state","value":"standby"}],"sub":false,"time_zone":"+02:00","uid":"eu1724765998599WwnVh","update_time":1724849519,"uuid":"326719f21e6675b1"}],"success":true,"t":1724856306870,"tid":"1e0f8d2b654c11ef883136d89ae34f8e"}}
2024-08-28 16:45:06.889 [TRACE] [ding.tuya.internal.cloud.TuyaOpenAPI] - Sending to 'https://openapi.tuyaeu.com/v1.0/iot-03/devices/factory-infos?device_ids=bfa6b9267dc1d5562anlkg': Method = {GET}, Headers = {Accept-Encoding: gzip, User-Agent: Jetty/9.4.54.v20240208, Signature-Headers: client_id, t: 1724856306888, client_id: dxkwxfg4vqrsps5h7g5j, sign: 5D8FA1F0CF7452E52724E544F5FA192BE7D09D9B6D6C5521635F2E89CB898933, access_token: 0dca559f7c6922696368ffd784120ba3, sign_method: HMAC-SHA256}, Content = {null}
2024-08-28 16:45:06.984 [TRACE] [a.internal.cloud.TuyaContentListener] - Received from 'https://openapi.tuyaeu.com/v1.0/iot-03/devices/factory-infos?device_ids=bfa6b9267dc1d5562anlkg': Code = {200}, Headers = {Content-Type: application/json;charset=UTF-8, Content-Length: 231, Connection: keep-alive, Date: Wed, 28 Aug 2024 14:45:06 GMT, Access-Control-Allow-Credentials: true, Access-Control-Allow-Headers: , Access-Control-Allow-Headers: access_token,Content-Type, Access-Control-Allow-Methods: POST, Access-Control-Allow-Methods: OPTIONS, Access-Control-Allow-Methods: GET, Access-Control-Allow-Methods: DELETE, Access-Control-Allow-Methods: PUT, Access-Control-Allow-Origin: https://iot.tuya.com,https://platform.tuya.com, Gateway-Info: highway, Server: Sec, Strict-Transport-Security: max-age=31536000}, Content = {{"code":60009001,"msg":"API permission package error. For the solution, see https://developer.tuya.com/en/docs/iot/authentication-method?id=Ka49gbaxjygox.","success":false,"t":1724856306971,"tid":"1e217e45654c11ef95a3c283ae9aa908"}}

For me this sounds like the “Authorization” API is not enabled. In fact this one is not available for me in my TUYA Cloud Project. I Added “Authorization Token Management” to the API Services as “Authorization” is not available for me.

Any idea?

Regards,

Hello. Im successfully add the breaker to Openhab 4, through IOT cloud. The project is connected and online.

But… there is no channels. It is empty and no buttons for manualy add them.

I see device in project and in app, im even can control it through app. But openhab see no channels. Its looks like the project do not give any info to openhab.

Hi @ReasonX,

I got mine working but without discovery. It looks like there is a bug in the binding that has to do with authentification to the TUYA server.

I added my tuya-device manually. But you need to get the Device-Local-Key for this e.g. using tuya-cli
GitHub - TuyaAPI/cli: :wrench: A CLI for Tuya devices
Just install on a linux system using npm (you can find the command on github) and then type in

tuya-cli wizard

You then need to provide your Cloud-API credentials and the Device-ID for your device. It will then print you the device-local-key.
I found the product-ID inside the Openhab-Logs (set the tuya binding to TRACE Mode). The binding tried to add my pool Heatpump and therefore displayed the informations inside the log.

Getting the DPs for your thing is also not that easy. I found a tutorial online:

GitHub - dulfer/localtuya-device-datapoints: List of data points for various Tuya devices, required to setup localtuya integration

You then have to decide what type of channel you need (string, number, switch) and insert your informations.

Regards,
Carlo

2 Likes

Hmm, I wonder if something changed on the Tuya side. I haven’t added a device in a fairly long time, so I haven’t seen this issue. If you haven’t already done so, can you submit an issue to the SmarthomeJ Github?

no solution, yet the same error on my side. (See a few posts above) In my case its a lightbulb, which would not be discovered as for the same “api error”

I opened an issue:

[BUG] TUYA Binding | API permission package error | Device not discovered · Issue #589 · smarthomej/addons (github.com)

Thx for this discription.
I got my Panel Heater working now.
Greets

Hi @cd-tronic,

thanks for all these infos that allowed me to get my tuya things working!

Note that you don’t need to install that neet tuya-api tool to get the product ID.

Go to the API Cloud explorer on tuya website (for me it’s https://eu.platform.tuya.com/cloud/explorer, change according to your data center).
Choose Device Management, and finally Query Device Details in Bulk to get your device info providing your device ID in main UI.