CoolKit-Technologies / ha-addon

Apache License 2.0
265 stars 121 forks source link

Constantly losing devices and does not use local LAN #82

Closed iamandymcinnes closed 2 years ago

iamandymcinnes commented 2 years ago

Hi

There are 2 fundemental issues that are making this addon unusable for me currently...

First off the addon constantly loses my devices and I have to go in to the addons UI and click the refresh button for it to poll your API to re-retrieve my list of devices as there will be a number of devices that say "Device is not under your account". I'm guessing there is some issue with the websocket connection maybe if a device loses connectivity and then reconnects?

Any way this is the situation frequently and home assistant then is unable to control those devices until I go in to the addon UI and refresh it.

image

The second issue is that the local LAN mode inherently doesn't work due to the way you have implemented all of these cloud service polls. If the addon cannot reach your servers, it should automatically fallback on LAN, and it should stop trying to constantly refresh the list of devices and their state from your cloud service. Instead it should be holding the state locally either in memory or some cache file and if it needs to requery the state of a device, it should do so locally i.e. by talking to the device, not to your cloud service.

I have proved the local LAN issue, by removing internet access to the network my sonoff devices are connected to, and then within 60 seconds, they all go unavailable after you try and fail to poll your cloud service.

Many thanks

Andy

coolkit-tony commented 2 years ago

Hi, Andy. Thanks for your feedback. I am rewriting the WebSocket connection code currently. By the way, I will create a new branch for rewriting the whole project. Sorry for the poor experience : (

iamandymcinnes commented 2 years ago

Hi

Just wondered how you are getting on with the websocket / project rewrite? Is there anything I can help test?

Many thanks

Andy

spilin commented 2 years ago

Hi, @coolkit-tony I'm experiencing same issues with losing devices every 1-2 weeks. Is there any update on the fix? Would very much appreciated any response. Thank you.

niezw commented 2 years ago

Hi, @coolkit-tony I'm experiencing same issues with losing devices every 1-2 weeks. Is there any update on the fix? Would very much appreciated any response. Thank you.

We will update a new version within this week. You can install it and try .

niezw commented 2 years ago

Please use the latest version, we have made some updates

If you still have this problem, please reopen the issue. If there are other problems, please create a new issue.

spilin commented 2 years ago

Hi, unfortunately issue persisted. I keep losing specific device, that comes back after clicking sync.

niezw commented 2 years ago

Hi, unfortunately issue persisted. I keep losing specific device, that comes back after clicking sync.

Can you make a video to recreate this phenomenon? Let's solve this problem better.