Skip to content
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

Online entities stay disconnected after wifi-router boot #362

Open
jlatvala opened this issue Oct 12, 2023 · 14 comments
Open

Online entities stay disconnected after wifi-router boot #362

jlatvala opened this issue Oct 12, 2023 · 14 comments
Labels
bug Something isn't working

Comments

@jlatvala
Copy link

The problem

I have seen this problem few times (maybe always when I reboot my wifi-router, not sure).

When I reboot my wifi-box, then my Easee Home and Equalizer binary_sensor.xxx_online entities will be marked as disconnected in HA.

When the wifi-box has rebooted and Easee Home and Equalizer have been connected again to my wifi network (I see it in Easee app), these entities stay in disconnected state in HA.
Everything else works, I can see correct states of all other entities and their values update correctly.

Rebooting HA changes these entities back to connected state.

Version of Easee integration having the issue?

0.9.55

Version of Home Assistant Core having the issue?

2023.10.1

Anything in the logs that might be useful for us?

No response

Additional information

No response

@jlatvala jlatvala added the bug Something isn't working label Oct 12, 2023
@jlatvala jlatvala changed the title Online entities stay offline after wifi-router boot Online entities stay disconnected after wifi-router boot Oct 12, 2023
@olalid
Copy link
Collaborator

olalid commented Oct 12, 2023

Hmm...
Is your HA connected to the WiFi router also or does it have internet connection independently from that?
There are a couple of attributes on the online sensors that would be interesting to know what their state is: "signalRConnected" and "lastestPulse".
signalRConnected shows the state of the signalR stream connection, if it is false, then the integration has fallen back to a polling mode.
lastestPulse is a timestamp that shows when data was latest received from the cloud.

@jlatvala
Copy link
Author

My HA is not open to internet (HA is connected to the same wifi as Easee Home and Equalizer).

Attributes before testing, HA was rebooted earlier, both devices's online status = connected.
Easee Home signalRConnected = true
Easee Home lastestPulse = '2023-10-13T10:34:19+03:00' (about 50 seconds ago)
Equalizer signalRConnected = true
Equalizer lastestPulse = '2023-10-13T10:34:11+03:00' (about 60 seconds ago)

Rebooted wifi box, actually two times.
Both devices's online status = disconnected. Waited more than 30 minutes, still status = disconnected.
Easee app shows that they are both connected to wifi.
Easee Home signalRConnected = false
Easee Home lastestPulse = '2023-10-13T10:34:19+03:00' (about 40 minutes ago, same time as above)
Equalizer signalRConnected = false
Equalizer lastestPulse = '2023-10-13T10:36:51+03:00' (about 38 minutes ago)

Rebooted HA, both devices's online status = connected.
Easee Home signalRConnected = true
Easee Home lastestPulse = '2023-10-13T11:19:10+03:00' (HA reboot time, about 20 seconds ago)
Equalizer signalRConnected = true
Equalizer lastestPulse = '2023-10-13T11:19:03+03:00' (HA reboot time, about 20 seconds ago)

@olalid
Copy link
Collaborator

olalid commented Oct 13, 2023

That is not what I meant with internet connection, I mean the access from HA to internet (and to Easee cloud specifically).
But from your description it seems like that connection is through the same router and therefore is lost during the reboot.

So there seems like there are 2 issues:

  1. The SignalR connection is not re-established after disconnect.
  2. The online sensor does not work when in polling mode.

I do not think it has anything to do with the chargers connection to WiFi, it probably the fact that HA looses the connection that triggers the problem.
I will try to reproduce it on my end.

@jlatvala
Copy link
Author

One more thing... At least sometimes, after wifi reboot, easee online entities are in state 'connected' for some time. And only after x minutes their state canges to 'disconnected'.

@olalid
Copy link
Collaborator

olalid commented Oct 13, 2023

There is a 17 minute timeout compared to the lastestPulse timestamp before a device is considered to be offline.
I guess that is what you are seeing?

@jlatvala
Copy link
Author

Might be, not sure if the delay was that long

@olalid
Copy link
Collaborator

olalid commented Oct 13, 2023

My initial attempt to reproduce this failed, for me the SignalR stream reconnected automatically after HA:s internet connection returned.
How long approximately does it take for your router to restart?

@jlatvala
Copy link
Author

This is just a guess, but normal reboot maybe 2-3 minutes? Less than 5 min, I guess.
Sorry can't try now, or I will hear "what are you doing, again, TV just froze" shouting from living room :)

Maybe you can try to unplug power cable from your router for 5 min, maybe 10 min?

@jlatvala
Copy link
Author

I have ' When Easee Home Online changes to Disconnected for 1:00' automation, which notifies my phone. I most probably wouldn't notice these disconnections without this automation.
And I have learnt that this automation fires always after wifi router reboot.

@olalid
Copy link
Collaborator

olalid commented Oct 14, 2023

I think I have some idea why the online logic does not work in polling mode, the polling logic has changed some time ago and how to detect if the charger is online in this mode was overlooked when that was changed.

But it is a mystery to me why on your end the SignalR stream does not reconnect after router reboot.
For me that works every time, as soon as internet connection returns to HA and the reconnect timeout (which starts out at 30 second and increases to 300 seconds max) it will reconnect and start operating normally. I do not need to restart HA for that to work.

I think to get any further on that we need to see some log files from your system.
If you enable debug logging by adding this in to your configuration.yaml:

logger:
  default: info
  logs:
    pyeasee: debug
    custom_components.easee: debug

And then trigger the error, maybe we could get some hints from the log file...

@jlatvala
Copy link
Author

I have today rebooted my wifi router more than 10 times. HA/Easee logging enabled and disabled.
Also unplugged wifi router's power cord for 5 minutes to make the reboot time longer.

And Easee Home & Equalizer both stay all the time connected to HA.
signalRConnected stays as true and latestPulse seems to be updating all the time.

The problem described in my initial bug report has happened for me multiple times since May 2023.
I reported this ticket while running HA 2023.10.1.

What is different now?
I have upgraded HA to 2023.10.3.
I have not yet upgraded to the new HA Operating system 11.0.

@olalid
Copy link
Collaborator

olalid commented Oct 15, 2023

Ok. Maybe some of the libraries that HA installs (and we use) could cause something like this.
I think I have been on 10.3, or at leat 10.2 all through this discussion.

The behaviour I expect (and that I have) is that signalRconnected goes false pretty soon after internet connection is lost.
Then the online status would go to offline a little less than 17 minutes later.
When internet connection returns, the integration would start updating again no later than 30 seconds later and signalRConnection would go true no later than 300 seconds later, and at that point online sensor would change to online again.

Well, if it happens again, please try to capture a log file.

@jlatvala
Copy link
Author

This happened again today.
I changed some DHCP / static ip settings in wifi router and after it, the router was longer time unreachable. And easee + equalizer got disconnected (signalRConnected = false).
Unfortunately I did not have easee logging enabled.

I enabled logging and made similar changes to wifi router settings and rebooted router few times.
Made similar changes again, second time, to wifi settings, rebooted few extra times.
But the problem didn't happen anymore. signalRConnected stays as true.

Just guessing, maybe this happens only after HA has been running longer time? Few days maybe?
Or after Easee has been connected to wifi longer time? Few days maybe?
It would explain why I can't see this error again, when I reboot wifi router again and again.

@olalid
Copy link
Collaborator

olalid commented Oct 17, 2023

Ok, depending on what hardware you are running your HA on it might be good if you leave debug logging on.
(I.e. if you are using SD-card for storage you might want to avoid that).

I do not think we will be able to deduct what your problem is by guessing, so we really need a log file to look at.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants