rospogrigio / localtuya

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

Failed to get status when installing ceiling light #101

Open snowgumrd opened 3 years ago

snowgumrd commented 3 years ago

Hi, I've been having issues trying to install a ceiling light that works normally in Tuya.

I can see the ip and the Device ID in config via the GUI, but it throws up an error, logged as below. I have an energy monitoring switch set up that works so I don't think the component files are the cause.

Logger: custom_components.localtuya.pytuya
Source: custom_components/localtuya/pytuya/__init__.py:462
Integration: LocalTuya (documentation)
First occurred: 7:22:34 PM (7 occurrences)
Last logged: 7:23:12 PM

[68xxxxxxxxxxxxxxxxxxx4a] Failed to get status: Expecting value: line 1 column 1 (char 0)
[68xxxxxxxxxxxxxxxxxxx4a] Failed to get status:

If if helps, it's also showing this other error in the logs:

Logger: custom_components.localtuya.config_flow
Source: custom_components/localtuya/pytuya/__init__.py:206
Integration: LocalTuya (documentation)
First occurred: 7:22:43 PM (2 occurrences)
Last logged: 7:23:12 PM

Unexpected exception
Traceback (most recent call last):
  File "/share/CACHEDEV1_DATA/.qpkg/Home-Assistant/CONFIG_DIR/custom_components/localtuya/config_flow.py", line 236, in async_step_basic_info
    self.dps_strings = await validate_input(self.hass, user_input)
  File "/share/CACHEDEV1_DATA/.qpkg/Home-Assistant/CONFIG_DIR/custom_components/localtuya/config_flow.py", line 172, in validate_input
    detected_dps = await interface.detect_available_dps()
  File "/share/CACHEDEV1_DATA/.qpkg/Home-Assistant/CONFIG_DIR/custom_components/localtuya/pytuya/__init__.py", line 460, in detect_available_dps
    data = await self.status()
  File "/share/CACHEDEV1_DATA/.qpkg/Home-Assistant/CONFIG_DIR/custom_components/localtuya/pytuya/__init__.py", line 422, in status
    status = await self.exchange(STATUS)
  File "/share/CACHEDEV1_DATA/.qpkg/Home-Assistant/CONFIG_DIR/custom_components/localtuya/pytuya/__init__.py", line 401, in exchange
    msg = await self.dispatcher.wait_for(seqno)
  File "/share/CACHEDEV1_DATA/.qpkg/Home-Assistant/CONFIG_DIR/custom_components/localtuya/pytuya/__init__.py", line 206, in wait_for
    await asyncio.wait_for(self.listeners[seqno].acquire(), timeout=timeout)
  File "/opt/Home-Assistant/lib/python3.8/asyncio/tasks.py", line 490, in wait_for
    raise exceptions.TimeoutError()
asyncio.exceptions.TimeoutError
postlund commented 3 years ago

I believe doesn't return the response we expect. Can you enable logging and post it here so we can debug?

logger:
  default: warning
  logs:
    custom_components.localtuya: debug
snowgumrd commented 3 years ago
logger:
  default: warning
  logs:
    custom_components.localtuya: debug

Sorry. Only just saw this. I'll enable the logger now. I'll check the log tomorrow and post what I find.

Update: As I mentioned on another issue, I can't get the integration working again. When I rolled back to 3.0.1, it keeps complaining that the integration can't be found so I've uninstalled it for now.

postlund commented 3 years ago

Did you manage to get any logs?

snowgumrd commented 3 years ago

Did you manage to get any logs?

No. Last time I tried, everything had fallen over with 3.0.3. I've just added a new switch today so I'll try the logger again.

snowgumrd commented 3 years ago

@postlund When I try to set up my light with 3.3, I get the response (Failed to authenticate with device. Verify that device id and local key are correct.) with log below:

Logger: custom_components.localtuya.pytuya Source: custom_components/localtuya/pytuya/init.py:515 Integration: LocalTuya (documentation) First occurred: 2:55:03 PM (1 occurrences) Last logged: 2:55:03 PM

[68xxxxxxxxxxxa] Failed to get status: Expecting value: line 1 column 1 (char 0) Traceback (most recent call last): File "/share/CACHEDEV1_DATA/.qpkg/Home-Assistant/CONFIG_DIR/custom_components/localtuya/pytuya/init.py", line 466, in detect_available_dps data = await self.status() File "/share/CACHEDEV1_DATA/.qpkg/Home-Assistant/CONFIG_DIR/custom_components/localtuya/pytuya/init.py", line 428, in status status = await self.exchange(STATUS) File "/share/CACHEDEV1_DATA/.qpkg/Home-Assistant/CONFIG_DIR/custom_components/localtuya/pytuya/init.py", line 413, in exchange payload = self._decode_payload(msg.payload) File "/share/CACHEDEV1_DATA/.qpkg/Home-Assistant/CONFIG_DIR/custom_components/localtuya/pytuya/init.py", line 515, in _decode_payload return json.loads(payload) File "/opt/Home-Assistant/lib/python3.8/json/init.py", line 357, in loads return _default_decoder.decode(s) File "/opt/Home-Assistant/lib/python3.8/json/decoder.py", line 337, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File "/opt/Home-Assistant/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)

And when I try with 3.1, the error shows (An unknown error occurred. See log for details.) log below shows up:

Logger: custom_components.localtuya.pytuya Source: custom_components/localtuya/pytuya/init.py:206 Integration: LocalTuya (documentation) First occurred: 2:55:13 PM (1 occurrences) Last logged: 2:55:13 PM

[68xxxxxxxxxxx4a] Failed to get status: Traceback (most recent call last): File "/share/CACHEDEV1_DATA/.qpkg/Home-Assistant/CONFIG_DIR/custom_components/localtuya/pytuya/init.py", line 466, in detect_available_dps data = await self.status() File "/share/CACHEDEV1_DATA/.qpkg/Home-Assistant/CONFIG_DIR/custom_components/localtuya/pytuya/init.py", line 428, in status status = await self.exchange(STATUS) File "/share/CACHEDEV1_DATA/.qpkg/Home-Assistant/CONFIG_DIR/custom_components/localtuya/pytuya/init.py", line 407, in exchange msg = await self.dispatcher.wait_for(seqno) File "/share/CACHEDEV1_DATA/.qpkg/Home-Assistant/CONFIG_DIR/custom_components/localtuya/pytuya/init.py", line 206, in wait_for await asyncio.wait_for(self.listeners[seqno].acquire(), timeout=timeout) File "/opt/Home-Assistant/lib/python3.8/asyncio/tasks.py", line 490, in wait_for raise exceptions.TimeoutError() asyncio.exceptions.TimeoutError

ALONG with

Logger: custom_components.localtuya.config_flow Source: custom_components/localtuya/pytuya/init.py:206 Integration: LocalTuya (documentation) First occurred: 2:55:13 PM (1 occurrences) Last logged: 2:55:13 PM

Unexpected exception Traceback (most recent call last): File "/share/CACHEDEV1_DATA/.qpkg/Home-Assistant/CONFIG_DIR/custom_components/localtuya/config_flow.py", line 238, in async_step_basic_info self.dps_strings = await validate_input(self.hass, user_input) File "/share/CACHEDEV1_DATA/.qpkg/Home-Assistant/CONFIG_DIR/custom_components/localtuya/config_flow.py", line 173, in validate_input detected_dps = await interface.detect_available_dps() File "/share/CACHEDEV1_DATA/.qpkg/Home-Assistant/CONFIG_DIR/custom_components/localtuya/pytuya/init.py", line 466, in detect_available_dps data = await self.status() File "/share/CACHEDEV1_DATA/.qpkg/Home-Assistant/CONFIG_DIR/custom_components/localtuya/pytuya/init.py", line 428, in status status = await self.exchange(STATUS) File "/share/CACHEDEV1_DATA/.qpkg/Home-Assistant/CONFIG_DIR/custom_components/localtuya/pytuya/init.py", line 407, in exchange msg = await self.dispatcher.wait_for(seqno) File "/share/CACHEDEV1_DATA/.qpkg/Home-Assistant/CONFIG_DIR/custom_components/localtuya/pytuya/init.py", line 206, in wait_for await asyncio.wait_for(self.listeners[seqno].acquire(), timeout=timeout) File "/opt/Home-Assistant/lib/python3.8/asyncio/tasks.py", line 490, in wait_for raise exceptions.TimeoutError() asyncio.exceptions.TimeoutError

postlund commented 3 years ago

@snowgumrd Can you try to install localtuya from master, enable debug logs, try to add your device and then paste the log here? It will help me trouble shoot this.