rospogrigio / localtuya

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

After Updating to 3.2.0 all Local Tuya Devices are unavailable #283

Closed LuckyTriple7 closed 3 years ago

LuckyTriple7 commented 3 years ago

I have updatet to the latest Version 3.2.0 After restarting Homeassistant, all Devices are unavailable.

image

When im reload the Integration, devices comes back until the next reboot. No error messages appear in the log.

Reverting back to 3.1.0 all works fine

GMTZMU commented 3 years ago

Hi, I have the same problem

KTibow commented 3 years ago

What do you see in logs?

oddboy commented 3 years ago

same issue here.. logs don't seem to have much of interest...

dragorex71 commented 3 years ago

Same. Downgrade to 3.1 and everything is fine again

beccsjb commented 3 years ago

May sound like a silly question, but how do you downgrade to 3.1?

Im having the same issue, all ~70 odd devices unavailable. Have even tried manually re adding some, with no change.

LuckyTriple7 commented 3 years ago

HACS -> Integrations -> Local Tuya -> REINSTALL

image

Select Version 3.1.0 -> INSTALL -> Restart HASS

image

beccsjb commented 3 years ago

HACS -> Integrations -> Local Tuya -> REINSTALL

image

Select Version 3.1.0 -> INSTALL -> Restart HASS

image

Legend! Cheers LuckyTriple7 - All backup and running :)

postlund commented 3 years ago

Please try #288.

KTibow commented 3 years ago

Enable debug logs with

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

Downgrading also worked for me.

AdmiralStipe commented 3 years ago

Please try #288.

Same problem here, I had to create an automation, which reloads localtuya one minute after HA restart, but I'm also thinking about reverting to 3.1.0 and staying there.

288 didn't help either - in fact sometimes it makes it even worse. Even after reload of localtuya some of the plugs remain unavailable, which was not the case before.

Log file shows no extra errors besides of already known: "File "/config/custom_components/localtuya/init.py", line 209, in _async_reconnect device = entry[TUYA_DEVICE] TypeError: string indices must be integers`"

KTibow commented 3 years ago

@AdmiralStipe What version are you on? I couldn't find the code device = entry[TUYA_DEVICE] anywhere on GitHub.

AdmiralStipe commented 3 years ago

Remaining at 3.2.0 for now despite the problems... it kinda works, but not the way I would like it to :).

KTibow commented 3 years ago

@AdmiralStipe This is what's at line 209: https://github.com/rospogrigio/localtuya/blob/master/custom_components/localtuya/__init__.py#L209 _async_reconnect isn't declared anywhere in the file either.

AdmiralStipe commented 3 years ago

Well, not sure what are you trying to tell me... the described error happened when i tried to use the pull request #288, not at normal 3.2.0 version, which I use now, if that's what you mean.

KTibow commented 3 years ago

I don't think you're running the latest version of that PR. This is what's at line 209: https://github.com/rospogrigio/localtuya/blob/simple_reconnect/custom_components/localtuya/__init__.py#L209

AdmiralStipe commented 3 years ago

I am not running it at all... as I said, I'm running the official latest release 3.2.0 from 30th December... just for testing I tried out the changes from PR288 about two weeks ago and when I did, the mentioned error appeared... then I switched back to official latest release. And I have no idea what is in which line and what it's supposed to do, as I'm no programmer... just stating, that I tried the PR, it didn't work for me, described the outcome and that's all.

KTibow commented 3 years ago

@AdmiralStipe Could you reinstall the latest version and see if you still get the same error?

AdmiralStipe commented 3 years ago

Once again, the "string indices must be integers" error does not happen with the latest version. Problem with the latest version (which I have already reinstalled just to be sure) is, that the devices become unavailable (at least at restart, possibly also later on) and I have to reload the integration after restart to make it run normally, as other users have reported. The "string indices must be integers" error happened, when I installed the PR288 over the latest version. So, after restart the devices were unavailable and also remained unavailable even after integration reload, additionally to that the "string indices must be integers" error appeared. Therefore I noticed about that and reinstalled the latest version without the PR288. So, now there is no "string indices must be integers" error anymore, but the inital "devices become unavailable" error remains at restart at least until reloading the integration. Hopefully I have made myself clear now.

homecb commented 3 years ago

@AdmiralStipe How do you reload the integration after restart?

AdmiralStipe commented 3 years ago

@AdmiralStipe How do you reload the integration after restart?

With this automation:

alias: _LocalTuya reload description: '' trigger:

Sorry, bad formatting here, but i guess you can see the point...

Final71 commented 3 years ago

I'm also having a similar issue I believe with Teckin SB50+ bulbs (Tuya - Smart Life). I find that I can almost randomly get them working when on 3.1.0 via YAML Configuration. I have other Teckin bulbs that do work perfectly fine in 3.1.0 but when I upgrade to 3.2.0 they all end up failing. Downgrade to 3.1.0 and things work again (Minus the SB50+ which I seem to have random luck getting back online since I power them off at night (may need to stop doing that..). On 3.1.0, WITHOUT PR#288 I get these logs:

2021-02-01 12:15:18 ERROR (MainThread) [custom_components.localtuya.common] [360...72f] Connect to 192.168.50.106 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 456, in exchange
return await self.exchange(command, dps)
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 501, in wait_for
raise exceptions.TimeoutError()
asyncio.exceptions.TimeoutError

If I upgrade to 3.2.0, I wont see anything special on my warning level, but if I enable debug on localtuya, I'll see this:

2021-02-01 12:25:41 DEBUG (MainThread) [custom_components.localtuya.discovery] Listening to broadcasts on UDP port 6666 and 6667
2021-02-01 12:25:43 DEBUG (MainThread) [custom_components.localtuya.light] [360...72f] Adding light.office_2 with configuration: {'platform': 'light', 'friendly_name': 'Office 2', 'id': 20, 'color_mode': 21, 'brightness': 22, 'color_temp': 23, 'color': 24, 'brightness_lower': 29, 'brightness_upper': 1000, 'color_temp_min_kelvin': 2700, 'color_temp_max_kelvin': 6500, 'scene': 25, 'music_mode': False}

In the above situation, on 3.2.0, none of my lights end up working, even the ones that were perfectly fine in 3.1.0.

Next, I pull in PR288 and end up with this result:

2021-02-01 12:43:12 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File "/config/custom_components/localtuya/__init__.py", line 216, in _async_reconnect
device = entry[TUYA_DEVICE]
TypeError: string indices must be integers
2021-02-01 12:43:12 ERROR (MainThread) [custom_components.localtuya.common] [360...72f] Connect to 192.168.50.106 failed
Traceback (most recent call last):
File "/config/custom_components/localtuya/common.py", line 149, in _make_connection
status = await self._interface.status()
File "/config/custom_components/localtuya/pytuya/__init__.py", line 472, in status
status = await self.exchange(STATUS)
File "/config/custom_components/localtuya/pytuya/__init__.py", line 467, in exchange
return await self.exchange(command, dps)
File "/config/custom_components/localtuya/pytuya/__init__.py", line 451, in exchange
msg = await self.dispatcher.wait_for(seqno)
File "/config/custom_components/localtuya/pytuya/__init__.py", line 240, in wait_for
await asyncio.wait_for(self.listeners[seqno].acquire(), timeout=timeout)
File "/usr/local/lib/python3.8/asyncio/tasks.py", line 501, in wait_for
raise exceptions.TimeoutError()
asyncio.exceptions.TimeoutError
2021-02-01 12:43:12 DEBUG (MainThread) [custom_components.localtuya.pytuya] [360...72f] Closing connection
2021-02-01 12:43:12 DEBUG (MainThread) [custom_components.localtuya.pytuya] [360...72f] Stopped heartbeat loop
2021-02-01 12:43:12 DEBUG (MainThread) [custom_components.localtuya.pytuya] [360...72f] Connection lost: None
2021-02-01 12:43:12 DEBUG (MainThread) [custom_components.localtuya.common] [360...72f] Disconnected - waiting for discovery broadcast

I hope this information helps, Happy to test more if need be, Please tag me if you need anymore info or have any suggestions.

LuckyTriple7 commented 3 years ago

3.2.2 fix this Problem for me, thx a lot !