rospogrigio / localtuya

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

Unable to add my devices - errors #133

Closed buzurk26 closed 3 years ago

buzurk26 commented 3 years ago

Hi,

I am having some issues with the LocalTuya Integration, I am getting errors when trying to add my devices.

I installed LocalTuya via HACS, all appeared to install without issue however when i try to add a device i get an error with a failure to authenticate.

Environment details -

HASSIO - 0.117.2 HACS - 1.6.1 LocalTuya - 3.0.3

I got my IDs using the TuyaAPI instructions here https://github.com/codetheweb/tuyapi/blob/master/docs/SETUP.md

Which when running the cli-wizard gave me an output like this [ { name: 'Study Lamp', id: '938xxxxxxxxxx60c', key: '93xxxxxxxxx0c' } ] Replaced with xxxx's just to mask it.

Assuming ID is my "Device ID" and Key is "Local Key" when trying to add my device on the integrations page

image

Logs showing the following

image

Log Detail

unexptected-exception.txt unexptected-exception-2.txt [93xxxxxx0c] Failed to get status.txt [938fxxxxxxxx60c] Failed to get status.txt [938xxxxxxx60c] Failed to get status Expecting value line 1 column 1 (char 0).txt

postlund commented 3 years ago

Please enable debug logs, run again and attach logs here. We be great if you could run from master instead since we have a few fixes there which is not in HACS.

https://github.com/rospogrigio/localtuya#debugging

buzurk26 commented 3 years ago

Hi,

I had that already enabled, where do i find the logs?

I added 3.0.3 via HACs, i only aded by adding your repo URL, wouldnt that pull the latest?

If not, do i uninstall via hacs first?

postlund commented 3 years ago

You only get the latest released version from HACS and there's hasn't been any releases from master in a while. You should remove it from HACS first, yes, and then add it under custom_components/localtuya.

The logs are in home-assiatant.log in your config directory. Can also be obtained from Configuration -> Logs and pressing the button at the bottom.

buzurk26 commented 3 years ago

Hi

thanks for that, i uninstalled and manually installed from master.

went to add again, same error

the lots i did upload above, are you able to see them?

postlund commented 3 years ago

Yes, I can see the logs but they are incomplete as you didn't have debug level enabled.

buzurk26 commented 3 years ago

hi, Here is what i had in my comfiguration.yaml, is that not right?

image

Thanks again for your help

buzurk26 commented 3 years ago

here is the latest log when i tried again, one thing is when i do add it, it comes back with that failed to authenticate almost straight away

`Log Details (ERROR)
Logger: custom_components.localtuya.pytuya
Source: custom_components/localtuya/pytuya/__init__.py:515
Integration: LocalTuya integration (documentation, issues)
First occurred: 23:03:45 (2 occurrences)
Last logged: 23:03:49

[1248xxxxxxxxxxxx61de] 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 466, in detect_available_dps
    data = await self.status()
  File "/config/custom_components/localtuya/pytuya/__init__.py", line 428, in status
    status = await self.exchange(STATUS)
  File "/config/custom_components/localtuya/pytuya/__init__.py", line 413, in exchange
    payload = self._decode_payload(msg.payload)
  File "/config/custom_components/localtuya/pytuya/__init__.py", line 515, in _decode_payload
    return json.loads(payload)
  File "/usr/local/lib/python3.8/json/__init__.py", line 357, in loads
    return _default_decoder.decode(s)
  File "/usr/local/lib/python3.8/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/local/lib/python3.8/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)`

Thank you

postlund commented 3 years ago

You need to pull the full log from the log file and not just the error itself. Try pressing the button at the bottom of the log page or download it from your config directory (home-assistant.log).

buzurk26 commented 3 years ago

Hey, i found it, sorry about that.

uploaded debug.txt

buzurk26 commented 3 years ago

Hi, Got it working, though not sure what happened, essentially removed it all, including devices from cloud and started again

thanks for your assistance.