-
Notifications
You must be signed in to change notification settings - Fork 561
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make connection retries every minute #288
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello postlund,
thanks for the code. I checked the code in both systems and i got errors
2021-01-01 14:52:36 ERROR (MainThread) [custom_components.localtuya.common] [453...66f] Connect to 192.168.200.202 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 457, in exchange
payload = self._decode_payload(msg.payload)
File "/config/custom_components/localtuya/pytuya/__init__.py", line 559, 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)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello postlund,
my mistake, old keys configured for some devices. : (
So it is working in my test and prod system without errors.
I can approve, if I am authorized to do so.
When i replace the init.py and restart HASS all Devices are unavailable, Error Messages below: `Logger: homeassistant Error doing job: Exception in callback _SelectorDatagramTransport._read_ready() Error doing job: Task exception was never retrieved |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello,
it is working now, also in my test systems. Great.!!!
But ;-)
If I disconnect or not available for a short time the device it will not reconnect again until i restart HA. The following error apears:
2021-01-01 14:33:00 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
Thank you so much
@Marco-Kl I managed to reproduce and hopefully fix that, can you update and try again? @LuckyTriple7 You must update all changed files, not just one of them. |
Updates 2 Files now: commony.py and init.py. `Logger: homeassistant Error doing job: Task exception was never retrieved |
Hello postlund, I will test it during this night. I have to improve my Python skills so that I can also provide better support and create integrations Thank you verry much. |
@Marco-Kl Great, thank you! 👍 @LuckyTriple7 I pushed an update, make sure you pull the latest files. |
OK my mistake. Debug LOG after reload: After restart HASS, Device is unavailable and NO Log entries for this Device "Airbowl Premium" with IP 192.168.178.132 |
Is this fix going to be incorporated into v 3.3.0? When will it be released? I am on 3.1.0 |
I think I have exact same problem. After Hass restart everything is unavailable and after a reload everything works perfectly. I found a way around it i have an automation that detect whether all the devices are loaded before starting homekit. I added the service to the end of that automation |
For what it's worth, I had to pull this PR into my fork which fully resolved my dropped devices issue. |
I will take a look at this PR again later today/tonight and make appropriate changes. Then we can merge it and make a release, hopefully it will help a lot of people. |
This mimics the re-connect loop previosuly present, but in a simpler form. Every 60 seconds, a new connection attempt is made as well as initially when a device is set up.
21886c2
to
da3432f
Compare
I have pushed an update, please try out the latest change and once we have confirmation that it works we'll make a new release. |
I was able to pull this down and test it against my HA which is on a different VLAN from the devices in question. I can confirm for me at least, that this PR allows devices to be available in HA where they previously were not |
@rospogrigio I think we should merge this (after regular review of course) and make a release. It will help a lot of people. Do you want to handle the release or share your regular "routine" so I can do it? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Hi @postlund , nice to read back from you! I just go to the Releases menu, press "Draft a new release", add a tag name, title and description and press "Publish release", I'm sure you knew hot to do it though. I'll do it now, the next time feel free to do it yourself if you believe you have an urgent fix you want to publish. Bye! |
Looking forward to try this (when I head back home in a month) |
@jfparis The passive connection logic is still there, but with this change is built on top of that. So connection attempts are made either if broadcast messages are received or every minute. So it'a not needed. |
@rospogrigio Same to you! Too busy nowadays... That sounds simple enough 😊 I think I shall manage! |
This mimics the re-connect loop previosuly present, but in a simpler
form. Every 60 seconds, a new connection attempt is made as well as
initially when a device is set up.
I will add this an option, enabled by default so we can still support devices that sleep. But I want to get this out for testing.