rospogrigio / localtuya

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

[Cover] Connection issue but works when toggling LED #207

Closed Matssa56 closed 3 years ago

Matssa56 commented 3 years ago

Hi,

I successfuly configured all my covers (9) as well as the LED on them through the integration directly (not via YAML).

When added, the cover commands are all grey, but not the LED. When toggling the LED, the commands become blue and I can use them.

I rebooted my HA instance and same issue, all the commands are grey but not the LED. Sans titre

In terms of logs, I don't see anything strange:

2020-12-02 08:34:23 DEBUG (MainThread) [custom_components.localtuya.pytuya] [780...867] Sending command heartbeat (device type: type_0a)
2020-12-02 08:34:23 DEBUG (MainThread) [custom_components.localtuya.pytuya] [780...867] Send payload: b'{}'
2020-12-02 08:34:23 DEBUG (MainThread) [custom_components.localtuya.pytuya] [780...867] Waiting for sequence number -100
2020-12-02 08:34:23 DEBUG (MainThread) [custom_components.localtuya.pytuya] [780...77e] Sending command heartbeat (device type: type_0a)
2020-12-02 08:34:23 DEBUG (MainThread) [custom_components.localtuya.pytuya] [780...77e] Send payload: b'{}'
2020-12-02 08:34:23 DEBUG (MainThread) [custom_components.localtuya.pytuya] [780...77e] Waiting for sequence number -100
2020-12-02 08:34:23 DEBUG (MainThread) [custom_components.localtuya.pytuya] [780...867] Dispatching message TuyaMessage(seqno=0, cmd=9, retcode=0, payload=b'', crc=2958142211)
2020-12-02 08:34:23 DEBUG (MainThread) [custom_components.localtuya.pytuya] [780...867] Got heartbeat response
2020-12-02 08:34:23 DEBUG (MainThread) [custom_components.localtuya.pytuya] [780...867] Decrypted payload: {}
2020-12-02 08:34:23 DEBUG (MainThread) [custom_components.localtuya.pytuya] [780...77e] Dispatching message TuyaMessage(seqno=0, cmd=9, retcode=0, payload=b'', crc=2958142211)
2020-12-02 08:34:23 DEBUG (MainThread) [custom_components.localtuya.pytuya] [780...77e] Got heartbeat response
2020-12-02 08:34:23 DEBUG (MainThread) [custom_components.localtuya.pytuya] [780...77e] Decrypted payload: {}

Here is when I swtich the LED:

2020-12-02 08:36:07 DEBUG (MainThread) [custom_components.localtuya.pytuya] [211...6de] Sending command set (device type: type_0a)
2020-12-02 08:36:07 DEBUG (MainThread) [custom_components.localtuya.pytuya] [211...6de] Send payload: b'{"devId":"21183627cc50e37576de","uid":"21183627cc50e37576de","t":"1606894567","dps":{"101":true}}'
2020-12-02 08:36:07 DEBUG (MainThread) [custom_components.localtuya.pytuya] [211...6de] Waiting for sequence number 86
2020-12-02 08:36:07 DEBUG (MainThread) [custom_components.localtuya.pytuya] [211...6de] Dispatching message TuyaMessage(seqno=86, cmd=7, retcode=0, payload=b'', crc=3522992189)
2020-12-02 08:36:07 DEBUG (MainThread) [custom_components.localtuya.pytuya] [211...6de] Dispatching sequence number 86
2020-12-02 08:36:07 DEBUG (MainThread) [custom_components.localtuya.pytuya] [211...6de] Decrypted payload: {}
2020-12-02 08:36:07 DEBUG (MainThread) [custom_components.localtuya.pytuya] [211...6de] Dispatching message TuyaMessage(seqno=0, cmd=8, retcode=0, payload=b'3.3\x00\x00\x00\x00\x00\x00\x006\x00\x00\x00\x01\x83\x01\xfc\x07Qn,\x13\xa5\x7f\xa5\xd9A&\x84\x9d\xc4_\xcd\xa1\xd9"\xf8\x89BI$\xea>\xfa@vO\x97!\xd8;\xc8\xe7\x13\x016<_\x19\xff\xd9\xfb\x84C@\x01yn\'8\xdaF\x0cE\x94p@5\x9f%\xba*\xfc\x191\xf1GW3HM3AR', crc=4254166411)
2020-12-02 08:36:07 DEBUG (MainThread) [custom_components.localtuya.pytuya] [211...6de] Got status update
2020-12-02 08:36:07 DEBUG (MainThread) [custom_components.localtuya.pytuya] [211...6de] Decrypted payload: {"devId":"21183627cc50e37576de","dps":{"101":true},"t":1606894566}
2020-12-02 08:36:07 WARNING (SyncWorker_22) [custom_components.localtuya.light] [211...6de] Entity light.led_volet_bureau is requesting unset index for option color_mode
2020-12-02 08:36:07 WARNING (SyncWorker_22) [custom_components.localtuya.light] [211...6de] Entity light.led_volet_bureau is requesting unknown DPS index None
2020-12-02 08:36:07 WARNING (SyncWorker_22) [custom_components.localtuya.light] [211...6de] Entity light.led_volet_bureau is requesting unset index for option color_mode
2020-12-02 08:36:07 WARNING (SyncWorker_22) [custom_components.localtuya.light] [211...6de] Entity light.led_volet_bureau is requesting unknown DPS index None
2020-12-02 08:36:07 WARNING (MainThread) [custom_components.localtuya.light] [211...6de] Entity light.led_volet_bureau is requesting unset index for option color_mode
2020-12-02 08:36:07 WARNING (MainThread) [custom_components.localtuya.light] [211...6de] Entity light.led_volet_bureau is requesting unknown DPS index None
2020-12-02 08:36:07 WARNING (MainThread) [custom_components.localtuya.light] [211...6de] Entity light.led_volet_bureau is requesting unset index for option color_mode
2020-12-02 08:36:07 WARNING (MainThread) [custom_components.localtuya.light] [211...6de] Entity light.led_volet_bureau is requesting unknown DPS index None
2020-12-02 08:36:09 DEBUG (MainThread) [custom_components.localtuya.pytuya] [211...6de] Sending command set (device type: type_0a)
2020-12-02 08:36:09 DEBUG (MainThread) [custom_components.localtuya.pytuya] [211...6de] Send payload: b'{"devId":"21183627cc50e37576de","uid":"21183627cc50e37576de","t":"1606894569","dps":{"101":false}}'
2020-12-02 08:36:09 DEBUG (MainThread) [custom_components.localtuya.pytuya] [211...6de] Waiting for sequence number 87
2020-12-02 08:36:09 DEBUG (MainThread) [custom_components.localtuya.pytuya] [211...6de] Dispatching message TuyaMessage(seqno=87, cmd=7, retcode=0, payload=b'', crc=208290232)
2020-12-02 08:36:09 DEBUG (MainThread) [custom_components.localtuya.pytuya] [211...6de] Dispatching sequence number 87
2020-12-02 08:36:09 DEBUG (MainThread) [custom_components.localtuya.pytuya] [211...6de] Decrypted payload: {}
2020-12-02 08:36:09 DEBUG (MainThread) [custom_components.localtuya.pytuya] [211...6de] Dispatching message TuyaMessage(seqno=0, cmd=8, retcode=0, payload=b'3.3\x00\x00\x00\x00\x00\x00\x007\x00\x00\x00\x01\x83\x01\xfc\x07Qn,\x13\xa5\x7f\xa5\xd9A&\x84\x9d\xc4_\xcd\xa1\xd9"\xf8\x89BI$\xea>\xfa@vH\xe64;~\xa7\x84t\x1d\x00?\xc9\xa0\xecb\\\x84\x7f\xa6b\nt\xf5\xfe\x02\x89=}\x06\x0eo\x15\x8aU\x92\xe9\x16*\x8d\xd7\xc3\x8d\xf1\xc6\xa8\xab\xf8\x9c', crc=3849691425)
2020-12-02 08:36:09 DEBUG (MainThread) [custom_components.localtuya.pytuya] [211...6de] Got status update
2020-12-02 08:36:09 DEBUG (MainThread) [custom_components.localtuya.pytuya] [211...6de] Decrypted payload: {"devId":"21183627cc50e37576de","dps":{"101":false},"t":1606894568}
2020-12-02 08:36:09 WARNING (SyncWorker_3) [custom_components.localtuya.light] [211...6de] Entity light.led_volet_bureau is requesting unset index for option color_mode
2020-12-02 08:36:09 WARNING (SyncWorker_3) [custom_components.localtuya.light] [211...6de] Entity light.led_volet_bureau is requesting unknown DPS index None
2020-12-02 08:36:09 WARNING (SyncWorker_3) [custom_components.localtuya.light] [211...6de] Entity light.led_volet_bureau is requesting unset index for option color_mode
2020-12-02 08:36:09 WARNING (SyncWorker_3) [custom_components.localtuya.light] [211...6de] Entity light.led_volet_bureau is requesting unknown DPS index None

I'm using the version 3.1.0 from HACS directly.

rospogrigio commented 3 years ago

@Matssa56 , can you please try PR #213 and tell me if it fixes your problem? Thank you

Matssa56 commented 3 years ago

@Matssa56 , can you please try PR #213 and tell me if it fixes your problem? Thank you

Hi thanks for your help! Not really sure how I can test this out easily. How can I apply this? Need to overwrite my files directly? Btw just found out that my devices loses the connections frequently and gets it back very fast, don't know why. Can't seem to find the log since I rebooted HA since.

I'm getting new errors as well, its seems like the timer that I added for the fake duration isn't taken into account, therefore the status in HA is completly KO and hangs when sending a command (like when I want to close it doesn't stop at the end the counter continues or the command isn't used). For example I close all of my blinds at a certain hour, on all 5 there are 2 that doesn't work that well :S

Exception in _update_handler when dispatching 'localtuya_78034461500291b3977e': ({'1': 'stop', '9': 25, '101': False},) Traceback (most recent call last): File "/config/custom_components/localtuya/common.py", line 245, in _update_handler self.status_updated() File "/config/custom_components/localtuya/cover.py", line 185, in status_updated time_diff = time.time() - self._timer_start TypeError: unsupported operand type(s) for -: 'float' and 'NoneType'
Exception in _update_handler when dispatching 'localtuya_58037028a4cf12cd1cf7': ({'1': 'stop', '9': 20, '101': False},) Traceback (most recent call last): File "/config/custom_components/localtuya/common.py", line 245, in _update_handler self.status_updated() File "/config/custom_components/localtuya/cover.py", line 185, in status_updated time_diff = time.time() - self._timer_start TypeError: unsupported operand type(s) for -: 'float' and 'NoneType'
Exception in _update_handler when dispatching 'localtuya_5803702898f4abbc55f4': ({'1': 'stop', '9': 25, '101': False},) Traceback (most recent call last): File "/config/custom_components/localtuya/common.py", line 245, in _update_handler self.status_updated() File "/config/custom_components/localtuya/cover.py", line 185, in status_updated time_diff = time.time() - self._timer_start TypeError: unsupported operand type(s) for -: 'float' and 'NoneType'
Exception in _update_handler when dispatching 'localtuya_58037028a4cf12cca76c': ({'1': 'stop', '9': 25, '101': False},) Traceback (most recent call last): File "/config/custom_components/localtuya/common.py", line 245, in _update_handler self.status_updated() File "/config/custom_components/localtuya/cover.py", line 185, in status_updated time_diff = time.time() - self._timer_start TypeError: unsupported operand type(s) for -: 'float' and 'NoneType'
Exception in _update_handler when dispatching 'localtuya_58037028d8bfc0534ed5': ({'1': 'stop', '9': 15, '101': False},) Traceback (most recent call last): File "/config/custom_components/localtuya/common.py", line 245, in _update_handler self.status_updated() File "/config/custom_components/localtuya/cover.py", line 185, in status_updated time_diff = time.time() - self._timer_start TypeError: unsupported operand type(s) for -: 'float' and 'NoneType'

I'm also getting these new errors, maybe linked to the dropout connection (when adding through the integration I could find these DPS before).

[580...5f4] Entity light.led_cinquieme_volet_salon is requesting unknown DPS index None
[580...76c] Entity light.led_deuxieme_volet_salon is requesting unset index for option color_mode
[580...76c] Entity light.led_deuxieme_volet_salon is requesting unknown DPS index None
[580...ed5] Entity light.led_premier_volet_salon is requesting unset index for option color_mode
[580...ed5] Entity light.led_premier_volet_salon is requesting unknown DPS index None
Matssa56 commented 3 years ago

For the connection issue,, here is the error that I found:

[780...77e] Connect to 192.168.XX.XXX failed
Traceback (most recent call last):
  File "/config/custom_components/localtuya/common.py", line 156, in _make_connection
    status = await self._interface.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 440, in exchange
    msg = await self.dispatcher.wait_for(seqno)
  File "/config/custom_components/localtuya/pytuya/__init__.py", line 239, in wait_for
    await asyncio.wait_for(self.listeners[seqno].acquire(), timeout=timeout)
  File "/usr/local/lib/python3.8/asyncio/tasks.py", line 498, in wait_for
    raise exceptions.TimeoutError()
asyncio.exceptions.TimeoutError
[780...867] Heartbeat failed (), disconnecting
[580...76c] Heartbeat failed (), disconnecting
[580...5f4] Heartbeat failed (), disconnecting
[580...ed5] Heartbeat failed (), disconnecting
[780...77e] Heartbeat failed (), disconnecting
Traceback (most recent call last):
  File "/config/custom_components/localtuya/pytuya/__init__.py", line 379, in heartbeat_loop
    await self.heartbeat()
  File "/config/custom_components/localtuya/pytuya/__init__.py", line 468, in heartbeat
    return await self.exchange(HEARTBEAT)
  File "/config/custom_components/localtuya/pytuya/__init__.py", line 440, in exchange
    msg = await self.dispatcher.wait_for(seqno)
  File "/config/custom_components/localtuya/pytuya/__init__.py", line 239, in wait_for
    await asyncio.wait_for(self.listeners[seqno].acquire(), timeout=timeout)
  File "/usr/local/lib/python3.8/asyncio/tasks.py", line 498, in wait_for
    raise exceptions.TimeoutError()
asyncio.exceptions.TimeoutError
Matssa56 commented 3 years ago

Hey guys the latest update fixed this issue for me 👍