rospogrigio / localtuya

local handling for Tuya devices
GNU General Public License v3.0
2.94k stars 562 forks source link

Connection to device succeeded but no datapoints found, #1468

Closed lcsneil closed 1 year ago

lcsneil commented 1 year ago
Tuya Clamp Power Meter PJ-MGW1103 ## The problem

Device connects fine to Tuya Cloud and works with the phone app no issues. Try to then configure it on localtuya. The device is found and I have put in the parameters from the web account and get error that device is found but no data points.

Environment

Using Version 5.2.1 (have also tried 5.0.0 with same results) HA running on RPi4 - Localtuya version: 5.2.1 - Home Assistant Core version: - [] Does the device work using the Home Assistant Tuya Cloud component ? X

DP dump

Provide Home Assistant traceback/logs

Logger: custom_components.localtuya.pytuya
Source: custom_components/localtuya/pytuya/__init__.py:450
Integration: LocalTuya integration ([documentation](https://github.com/rospogrigio/localtuya/), [issues](https://github.com/rospogrigio/localtuya/issues))
First occurred: 07:47:41 (1 occurrences)
Last logged: 07:47:41

[bf9...9hp] Failed to get status:
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/asyncio/tasks.py", line 490, in wait_for
    return fut.result()
           ^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/asyncio/locks.py", line 387, in acquire
    await fut
asyncio.exceptions.CancelledError

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/config/custom_components/localtuya/pytuya/__init__.py", line 863, in detect_available_dps
    data = await self.status()
           ^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/localtuya/pytuya/__init__.py", line 795, in status
    status = await self.exchange(DP_QUERY)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/localtuya/pytuya/__init__.py", line 769, in exchange
    msg = await self.dispatcher.wait_for(seqno, payload.cmd)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/localtuya/pytuya/__init__.py", line 450, in wait_for
    await asyncio.wait_for(self.listeners[seqno].acquire(), timeout=timeout)
  File "/usr/local/lib/python3.11/asyncio/tasks.py", line 492, in wait_for
    raise exceptions.TimeoutError() from exc
TimeoutError

Additional information

localTuya

e3drigs commented 1 year ago

Sharing this problem trying to set up localtuya for first time today. HA 2023.7.3 localTuya 5.2.1

Attempting to add heaters and bulbs both yield same message and stack trace.

gh69 commented 1 year ago

I have had this same issue for nearly a year now on multiple versions. I'm currently using HA core 2023.7.3 and the latest HACS localTuya version and I just tried getting it to work again (since my free year of Tuya cloud is almost up) but I am still seeing the same problem. I only have 1 Tuya compatible device on my account and on my network. It is a pet feeder, which has a "Tuya Scene" (this toggles the feeder switch) and a security camera. These show up as 2 separate devices on the regular cloud based Tuya integration but they both work perfectly there. I have not been able to get anything to work on Local Tuya. i've got the device id and the looked-up local_key but when I attempt to add the device using protocol version 3.3, I immediately get the error "Connection to device succeeded but no datapoints found, please try again. Create a new issue and include debug logs if problem persists." If I attempt to add the device with protocol version 3.4, it spins there for a minute before coming back with that same error.

gootr00 commented 1 year ago

I have the sam problem. I cannot get the camera's in homeassistant tuya nor localtuya.

gh69 commented 1 year ago

I actually have no problems with the camera using the regular cloud-based tuya integration. With the cloud-based tuya integration the cam shows up as a sensor and all of it's extras show up as configuration controls (flip [switch], motion alarm [switch], motion detection sensitivity [drop down list], motion recording [switch], record mode [drop down list], video recording [switch]) and they all work great. The localtuya integration is where I'm seeing the no-datapoints-found error and this is preventing me from using the camera and replacing the cloud-based tuya integration with the localtuya integration.

I'm curious, gootr00, do you see this same error with the cloud-based tuya integration as well?

Justmeagene commented 1 year ago

Same here cloud-based tuya works but got the same error as lcsneil in the local tuya

hope its fixet soon

imadegunawinangun commented 1 year ago

Im facing same issue

shazn786 commented 1 year ago

i am also getting this same error while trying to add a breaker with energy monitor feature, whereas i am using 7 other on/off switches with energy monitor (the switches work fine while also giving me readings regarding current, voltage and watts usage)

config_entry-localtuya-0f4d0723e6185c802cc31923261f5da4.json.txt

localtuya-0f4d0723e6185c802cc31923261f5da4-Mains Breaker-EM-1141bd2eb8eaf4a4c7747b146b792e97.json.txt

meierthomas commented 1 year ago

While local-tuya works fine for me for my Wifi smart dimmers I have the same issues reported here when trying to add an outdoor RGB LED; i.e.

Connection to device succeeded but no datapoints found, please try again. Create a new issue and include debug logs if problem persists.

Log file of the process of adding the RGB LED home-assistant_localtuya_2023-08-13T01-44-40.548Z.log

I can add the device in the Tuya Smart app and it works fine. When adding it to Home Assistant I get the above error.

Did a bit more digging around datapoints. I have used the method described by Jimmy James (https://www.youtube.com/watch?v=Q1ZShFJDvE0&t=372s) to find the keys. In the referenced time stamp he also shows how to check the info on data points from the IOT cloud service. I have done the same with the RGB light and I don't get a dp_id: value as shown in the video from Jimmy James; i.e.

image

What I get from my light is the following specs; you see that dp_id is missing from my RGB LED

image

So I wonder whether there's a firmware issue or a setting to make this available...

Milliamper commented 1 year ago

Same issue here too with PJ-1103 WiFi Digital Meter

shazn786 commented 1 year ago

i have switched to standard toya integration by Home Assistant and problem resolved. Now the WiFi breaker with energy meter works fine and all the entities are displayed ie current, voltage and energy for phase A, B, C (though B and C have zero values as this is a single phase device, so i disabled the entities for B and C)

On Wed, Aug 16, 2023 at 11:37 PM Márton Szalai @.***> wrote:

Same issue here too with PJ-1103 WiFi Digital Meter

  • I have tried Local Tuya integration, with and without Cloud API
  • I also tried downloading and using the Local Tuya master branch
  • The Tuya integration shows that "WiFi Digital Meter (unsupported)", so it doesn't list any entities
  • And I also renewed my subscription to Tuya IoT
  • And many-many restarts and Local Tuya reinstallations

— Reply to this email directly, view it on GitHub https://github.com/rospogrigio/localtuya/issues/1468#issuecomment-1681098310, or unsubscribe https://github.com/notifications/unsubscribe-auth/A5Q3KNAQXWHZQCFGFQSDIALXVUHNTANCNFSM6AAAAAA24KDP7E . You are receiving this because you commented.Message ID: @.***>

gh69 commented 1 year ago

Just so there's no confusion...the problem technically isn't resolved, as the "no datapoints found" issue is with LocalTuya. The standard Tuya integration does work for many of us but it requires that cloud connection, which is what LocalTuya helps us get away from.

shazn786 commented 1 year ago

yes you are right

On Thu, Aug 17, 2023 at 12:25 AM gh69 @.***> wrote:

Just so there's no confusion...the problem technically isn't resolved, as the "no datapoints found" issue is with LocalTuya. The standard Tuya integration does work for many of us but it requires that cloud connection, which is what LocalTuya helps us get away from.

— Reply to this email directly, view it on GitHub https://github.com/rospogrigio/localtuya/issues/1468#issuecomment-1681156902, or unsubscribe https://github.com/notifications/unsubscribe-auth/A5Q3KNGCVYOBJON2GBTIY2DXVUND3ANCNFSM6AAAAAA24KDP7E . You are receiving this because you commented.Message ID: @.***>

deimosfr commented 1 year ago

I'm geting the same issues :(

xZetsubou commented 1 year ago

There are 2 main reason that can cause this error, as far that I know

  1. That you chose the wrong protocol version.
  2. The device is busy due to another client connected and using the device, e.g [ Tuya app, smart life app and other local integration ] Don't remove them just close those apps you need to make sure to the device you are trying to set it up isn't used by any other client also isn't used locally in another HA instance.

Some said restart router or HA can fix this issue is probably because by restarting those u probably disconnected the client that connected to the device.

meierthomas commented 1 year ago

Just a quick update that I was able to successfully add the device via Tuya Local. I know this doesn't really address why it's not working in LocalTuya but at least there's a workaround. I'm also impressed that both integrations can coexist (i.e. Tuya Local and LocalTuya)

lcsneil commented 1 year ago

There are 2 main reason that can cause this error, as far that I know

  1. That you chose the wrong protocol version.
  2. The device is busy due to another client connected and using the device, e.g [ Tuya app, smart life app and other local integration ] Don't remove them just close those apps you need to make sure to the device you are trying to set it up isn't used by any other client also isn't used locally in another HA instance.

Some said restart router or HA can fix this issue is probably because by restarting those u probably disconnected the client that connected to the device.

I can't be sure enough I haven't used this repo since months I use my fork tho I haven't modify pytuya yet.

Tried removing localtuya, rebooting, installed xZetsubou' fork reboot and and got exactly the same issue (with all 4 protocol versions). No datapoints found.

lcsneil

lcsneil commented 1 year ago

Ok - I have solved it for me. End user error. Given that others sound like they have the same symptoms I will embarrass myself by admitting what I did wrong. Basically RTFM!

I was using the 'secret' key on the Tuya cloud account, as the local key. This is NOT the one you need for the local key. That you find as per the instructions. Using that cloud key as the local one gives you device found but no data points as per my original problem.

As the installations instructions say... Under "Devices Management", select the "Query Device Details in Bulk" function, and enter your Device IDs, separated by commas. In the results you should see your local_key.

Off to hang my head in shame ........

lcsneil

martinvana commented 10 months ago

Adding to the mix - in case someone else may benefit: I was scratching my head for a while for the exactly same reason. In my case the integration pre-filled the Local key so I didn't doubt it. However, rebooting the entire HomeAssistant yielded a different Local key and that fixed the issue. :-)

rgnyldz commented 6 months ago

I get this error message with 5.2.1 and Local key, ip address of the device, user id etc are all set up correctly.

Tho in my old home assistant instance where I use 3.2.4.2 with the protocol version 3.5 everything is working fine. in 5.2.1 there is no 3.5 protocol version.

Below is my log;

This error originated from a custom integration.

Logger: custom_components.localtuya.pytuya
Source: custom_components/localtuya/pytuya/__init__.py:863
integration: LocalTuya (documentation, issues)
First occurred: 2:30:06 AM (1 occurrences)
Last logged: 2:30:06 AM

[bfe...y6p] Failed to get status:
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/asyncio/tasks.py", line 520, in wait_for
    return await fut
           ^^^^^^^^^
  File "/usr/local/lib/python3.12/asyncio/locks.py", line 386, in acquire
    await fut
asyncio.exceptions.CancelledError

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/config/custom_components/localtuya/pytuya/__init__.py", line 863, in detect_available_dps
    data = await self.status()
           ^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/localtuya/pytuya/__init__.py", line 795, in status
    status = await self.exchange(DP_QUERY)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/localtuya/pytuya/__init__.py", line 769, in exchange
    msg = await self.dispatcher.wait_for(seqno, payload.cmd)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/localtuya/pytuya/__init__.py", line 450, in wait_for
    await asyncio.wait_for(self.listeners[seqno].acquire(), timeout=timeout)
  File "/usr/local/lib/python3.12/asyncio/tasks.py", line 519, in wait_for
    async with timeouts.timeout(timeout):
  File "/usr/local/lib/python3.12/asyncio/timeouts.py", line 115, in __aexit__
    raise TimeoutError from exc_val
TimeoutError
JSferry commented 5 months ago

Stò provando a configurare la centralina _RainPoint TTV103FRFwifi con localTuya ma ricevo anche io lo stesso errore:

La connessione al dispositivo è riuscita ma non sono stati trovati i datapoint, riprova. Crea un nuovo Issue e includi i log di debug se il problema persiste.

Quello che ho potuto notare è che il configuratore di localTuya trova solo l'HUB connesso alla rete. Non posso aggiungere ne la valvola ne la presa perchè la loro local_key è vuota, l'unico ad averla è l' HUB.

Effettuando un controllo attraverso il pannello sviluppatore di Tuya IoT Platform, rispettivamente in Cloud > Development > My Project > Devices è possibile notare che l'HUB non ha nessun DP instruction, mentre la Valvola di controllo dell'acqua (Water valve controller) e la Presa (Socket)" si, ma senza _localkey non riesco ad aggiungerle.

Qualcuno si trova nella mia stessa situazione ed è riuscito ad ovviare al problema in qualche modo??

Di seguito il debug dell'errore:

Questo errore ha avuto origine da un'integrazione personalizzata.

Registratore: custom_components.localtuya.pytuya
Fonte: custom_components/localtuya/pytuya/__init__.py:863
Integrazione: LocalTuya (documentazione, problemi)
Prima occorrenza: 17:55:08 (1 occorrenze)
Ultima registrazione: 17:55:08

[bfb...tma] Failed to get status: could not decrypt data: wrong local_key? (exception: Expecting value: line 1 column 1 (char 0))
Traceback (most recent call last):
  File "/config/custom_components/localtuya/pytuya/__init__.py", line 953, in _decode_payload
    json_payload = json.loads(payload)
                   ^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/json/__init__.py", line 346, in loads
    return _default_decoder.decode(s)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/config/custom_components/localtuya/pytuya/__init__.py", line 863, in detect_available_dps
    data = await self.status()
           ^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/localtuya/pytuya/__init__.py", line 795, in status
    status = await self.exchange(DP_QUERY)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/localtuya/pytuya/__init__.py", line 780, in exchange
    payload = self._decode_payload(msg.payload)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/localtuya/pytuya/__init__.py", line 955, in _decode_payload
    raise DecodeError(
custom_components.localtuya.pytuya.DecodeError: could not decrypt data: wrong local_key? (exception: Expecting value: line 1 column 1 (char 0))
LangerFeen commented 2 months ago

I had to select a lower protocol version 3.3 in the device config because the device wouldn't accept/respond to protocol version 3.4

dombrowa commented 2 months ago

Another cause can be that the devices key in the cloud changed (this happened to one of my devices) "Error when adding in Local Tuya Connection to device succeeded but no datapoints found, please try again. Create a new issue and include debug logs if problem persists. " apparently indicates that the device/endpoint is found (local tuya can find this IP and likely connect to ist servce) but not necessarily query the device because it needs a valid key to authenticate any request. The error message is not clear IMHO.