rospogrigio / localtuya

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

cannot add cover entity #234

Open zakariajado opened 3 years ago

zakariajado commented 3 years ago

Thanks for the integration!

It is working with 1Gang and 3Gang bingoelec smart switch, but didn't manage to make it work with the COVER from Bingoelec with the following log details,

Logger: custom_components.localtuya.config_flow
Source: custom_components/localtuya/pytuya/__init__.py:140
Integration: LocalTuya (documentation, issues)
First occurred: 10:09:34 AM (2 occurrences)
Last logged: 10:12:13 AM

Unexpected exception
Traceback (most recent call last):
  File "/config/custom_components/localtuya/pytuya/__init__.py", line 499, in detect_available_dps
    data = await self.status()
  File "/config/custom_components/localtuya/pytuya/__init__.py", line 461, in status
    status = await self.exchange(STATUS)
  File "/config/custom_components/localtuya/pytuya/__init__.py", line 446, in exchange
    payload = self._decode_payload(msg.payload)
  File "/config/custom_components/localtuya/pytuya/__init__.py", line 543, in _decode_payload
    raise Exception(f"Unexpected payload={payload}")
Exception: Unexpected payload=b'json obj data unvalid'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/config/custom_components/localtuya/config_flow.py", line 260, in async_step_basic_info
    self.dps_strings = await validate_input(self.hass, user_input)
  File "/config/custom_components/localtuya/config_flow.py", line 173, in validate_input
    detected_dps = await interface.detect_available_dps()
  File "/config/custom_components/localtuya/pytuya/__init__.py", line 501, in detect_available_dps
    self.exception("Failed to get status: %s", e)
  File "/config/custom_components/localtuya/pytuya/__init__.py", line 140, in exception
    return self._logger.log(logging.EXCEPTION, msg, *args)
AttributeError: module 'logging' has no attribute 'EXCEPTION'

I appreciate your help and guidance, thanks

zakariajado commented 3 years ago

using most updated release did not help


2020-12-16 06:13:16 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bff...ezr] Started heartbeat loop
2020-12-16 06:13:16 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bff...ezr] Sending command heartbeat (device type: type_0a)
2020-12-16 06:13:16 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bff...ezr] Send payload: b'{}'
2020-12-16 06:13:16 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bff...ezr] Waiting for sequence number -100
2020-12-16 06:13:16 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bff...ezr] Dispatching message TuyaMessage(seqno=0, cmd=9, retcode=0, payload=b'', crc=2958142211)
2020-12-16 06:13:16 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bff...ezr] Got heartbeat response
2020-12-16 06:13:16 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bff...ezr] Sending command status (device type: type_0a)
2020-12-16 06:13:16 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bff...ezr] Send payload: b'{"gwId":"bfffe39a29156f1e73yezr","devId":"bfffe39a29156f1e73yezr"}'
2020-12-16 06:13:16 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bff...ezr] Waiting for sequence number 1
2020-12-16 06:13:16 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bff...ezr] Decrypted payload: {}
2020-12-16 06:13:16 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bff...ezr] Dispatching message TuyaMessage(seqno=1, cmd=10, retcode=1, payload=b'json obj data unvalid', crc=4140902751)
2020-12-16 06:13:16 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bff...ezr] Dispatching sequence number 1
2020-12-16 06:13:16 ERROR (MainThread) [custom_components.localtuya.pytuya] [bff...ezr] Failed to get status: Unexpected payload=b'json obj data unvalid'
Traceback (most recent call last):
File "/config/custom_components/localtuya/pytuya/__init__.py", line 505, in detect_available_dps
data = await self.status()
File "/config/custom_components/localtuya/pytuya/__init__.py", line 467, in status
status = await self.exchange(STATUS)
File "/config/custom_components/localtuya/pytuya/__init__.py", line 452, in exchange
payload = self._decode_payload(msg.payload)
File "/config/custom_components/localtuya/pytuya/__init__.py", line 549, in _decode_payload
raise Exception(f"Unexpected payload={payload}")
Exception: Unexpected payload=b'json obj data unvalid'
2020-12-16 06:13:16 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bff...ezr] Closing connection
2020-12-16 06:13:16 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bff...ezr] Stopped heartbeat loop
2020-12-16 06:13:16 ERROR (MainThread) [custom_components.localtuya.config_flow] Unexpected exception
Traceback (most recent call last):
File "/config/custom_components/localtuya/config_flow.py", line 260, in async_step_basic_info
self.dps_strings = await validate_input(self.hass, user_input)
File "/config/custom_components/localtuya/config_flow.py", line 173, in validate_input
detected_dps = await interface.detect_available_dps()
File "/config/custom_components/localtuya/pytuya/__init__.py", line 505, in detect_available_dps
data = await self.status()
File "/config/custom_components/localtuya/pytuya/__init__.py", line 467, in status
status = await self.exchange(STATUS)
File "/config/custom_components/localtuya/pytuya/__init__.py", line 452, in exchange
payload = self._decode_payload(msg.payload)
File "/config/custom_components/localtuya/pytuya/__init__.py", line 549, in _decode_payload
raise Exception(f"Unexpected payload={payload}")
Exception: Unexpected payload=b'json obj data unvalid'
2020-12-16 06:13:16 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bff...ezr] Connection lost: None

postlund commented 3 years ago

The json obj data unvalid is a known problem, not sure if we have a solution to that. It would be great if you could try to list datapoints with tuya-cli and see if that works.

https://github.com/TuyaAPI/cli

zakariajado commented 3 years ago

Thanks indeed for your reply, I am not sure how to do that, a guidance is appreciated.

However, the cover work with another custom_components with 2 for on(open cover), 1 for off(close cover), 3 for stop(stop cover) and it is a 2 button curtain switch, please check out the component here https://github.com/zakariajado/localtuya_cover_mod/tree/main/localtuya_cover

I really hope that this will help and any guidance is appreciated

Thanks!