rospogrigio / localtuya

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

No longer able to add Light that became unavailable #1106

Open DravenSA opened 2 years ago

DravenSA commented 2 years ago

Light bulb became unavailable. Removed it from HA and tried to re-add it, got the following error Connection to device succeeded but no datapoints found, please try again. Create a new issue and include debug logs if problem persists. then checked Logfile

 Logger: custom_components.localtuya.pytuya
Source: custom_components/localtuya/pytuya/__init__.py:623
Integration: LocalTuya integration ([documentation](https://github.com/rospogrigio/localtuya/), [issues](https://github.com/rospogrigio/localtuya/issues))
First occurred: 09:30:31 (2 occurrences)
Last logged: 09:36:12

[bf0...mme] Failed to get status: Expecting value: line 1 column 1 (char 0)
Traceback (most recent call last):
  File "/config/custom_components/localtuya/pytuya/__init__.py", line 574, in detect_available_dps
    data = await self.status()
  File "/config/custom_components/localtuya/pytuya/__init__.py", line 507, in status
    status = await self.exchange(STATUS)
  File "/config/custom_components/localtuya/pytuya/__init__.py", line 492, in exchange
    payload = self._decode_payload(msg.payload)
  File "/config/custom_components/localtuya/pytuya/__init__.py", line 623, in _decode_payload
    return json.loads(payload)
  File "/usr/local/lib/python3.10/json/__init__.py", line 346, in loads
    return _default_decoder.decode(s)
  File "/usr/local/lib/python3.10/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/local/lib/python3.10/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)

System Home Assistant 2022.10.5 Supervisor 2022.10.0 Operating System 9.3 Frontend 20221010.0 - latest

HACS Integration version: | 1.28.3 Frontend version: | 20220906112053

Local Tuya v4.1.1

Using Tuya App Yes

Light still works perfect through the cloud based Tuya App both in Home Assistant on on Mobile device.

gabrielpossimoser commented 2 years ago

Não sai da tela

ImSkully commented 2 years ago

Also having the same issue, seems you can only configure a light once and if it ever needs to be added again it will not work.

DravenSA commented 2 years ago

Will this ever get looked at? Screenshot 2022-11-03 171738 The longer we wait, the more updates that come out,

Now running HA 2022.11 Problem still the same

DravenSA commented 2 years ago

So, with sheer frustration I fixed it.

I removed the light from the SmartLife app (Tuya), and deleted all data pertaining to it,

I then added the light again, (it failed a few times, but i eventually got there) I then noticed it had a new Device id, (so that was good news) I went through the process to get the Local Key (this was also different from the old one) Once back into Home assistant added a new device through Local Tuya.

All back up and running now. Bit of a pest, but this worked for me.

donburch888 commented 1 year ago

I have also had this happen occasionally when re-adding devices. Worst case was to delete the device from LocalTuya, go back to tuya website and check the local key. OK, i probably did a reset on the device while trying to reconnect.

If device has been reset the Local Key will change, and (quite reasonably) LocalTuya will not connect to it using the old local key. Using the new Local Key works without any problem.

Thinks, maybe the wording of the error message should be changed to something like "Unable to connect to device with this local key. Please check and try again" ?