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

Lose connection to HA after PC Sleep #71

Closed
ad314159 opened this issue Jan 8, 2022 · 36 comments
Closed

Lose connection to HA after PC Sleep #71

ad314159 opened this issue Jan 8, 2022 · 36 comments
Assignees
Labels
bug Something isn't working

Comments

@ad314159
Copy link

ad314159 commented Jan 8, 2022

I have added entities to my Stream Deck using this plugin and everything functions as it should. The connection using a local network URL and Long-Lived Access Token works and I am able to add multiple, working entities on my Stream Deck.

After I leave my PC for several hours, it enters "Sleep" mode (or it can be put into sleep mode using power options). A button press on my keyboard or my Stream Deck is able to wake the PC up. However, pressing an entity button on the Stream Deck results in a yellow exclamation icon on the button and no action being performed. The other, native Stream Deck buttons/actions continue working fine.

In order to get this HA plugin working again, I need to close the Stream Deck companion application and re-open it. Then all works as it should.

No error messages in tmy HA logs.

Stream Deck: 5.1.4.14753
HA: 2021.12.8

@cgiesche
Copy link
Owner

cgiesche commented Jan 8, 2022

Hmm, my pc enters sleep mode often, and i am not facing that problem. After it woke up, all icons once flash the eclamation icon and then return to normal operation :/

Edit: I have debugging enabled for stream deck app - maybe this changes the plugins behaviour... I will check.

@ad314159
Copy link
Author

ad314159 commented Jan 9, 2022

I will try a re-install, as well as using the external URL instead of the local IP.

@ad314159
Copy link
Author

I have reinstalled, checked that the plugin files are where they should be (in appdata) and used both the external URL and internal IP. I was able to get it to respond a few times, however, most of the time, a restart of the Stream Deck app is required to get the Home Assitant buttons working again.

I believe the issue may be with Windows 10 power management and adapter configurations. Perhaps the connection to Home Assistant is not being done upon return from sleep at the right time. I have disabled Energy Efficient Ethernet, as well as Wait for Link, but am still having the same problem. I will continue testing other settings/options.

@ad314159
Copy link
Author

I have played around with Windows 10 settings for Sleep and WOL. As of now, the issue persists. My PC is set to sleep after 60 minutes, hibernate never.

On initial boot, everything works fine. The application loads, plugin loads, and all Home Assistant icons briefly show a green checkmark while starting up. Pressing the buttons works as they are supposed to. The Server Settings show that the Home Assistant URL (internal IP) and Long Access Token are valid (green check marks).

Once the PC goes to sleep (either on its own over time, or using Start -> Power -> Sleep), the plugin does not seem to reconnect to Home Assistant on wake. Pressing the buttons does nothing, and toggles/status are not updated.

@benji101
Copy link

benji101 commented Apr 1, 2022

I'm experiencing the exact same problem. I'm on Windows 11 and everytime my PC comes back from sleep, pressing any of my Home Assistant shortcut shows an exclamation mark. Restarting the Stream Deck application makes it fine again. I'm using a Stream Deck mini plugged in a USB 2.0 port (if that can make any difference).

@snadams
Copy link

snadams commented Jun 13, 2022

I am also experiencing this problem. Same as described above, after my PC goes to sleep the home assistant buttons no longer work until I restart the stream deck app. Not sure if anyone has figured out a fix for this.

@glnces
Copy link

glnces commented Jun 15, 2022

Same on Windows 11. I have a similar issue with the BarRaider World time plugin too, so I think it may be something happening on the Stream Deck side.

@cgiesche
Copy link
Owner

I am using Windows 11, newest StreamDeck and HomeAssistant plugin an still can not reproduce the problem (neither with hibernate nor with standby)...
Unfortunately it is very hard (nearly impossible) to fix a problem that i can not reproduce :(

@benji101
Copy link

I think @glnces is right, it looks on Stream Deck side. I have the weather widget and the issue appears for it too, at the same time (same thing for a date widget too). It looks like the stream deck lose connection with third party plugins after some time. But the media keys and folder navigation continues to work. Strange. And very annoying.

@ad314159
Copy link
Author

I think it has to do with the webhooks losing connection on sleep. The connection can be re-established by exiting the stream deck app and opening it again, or rebooting/restarting your home assistant. I have disabled all network power saving features and enabled Wake on LAN, so my network card should not be shutting down on sleep.

The only other difference I have in my setup, is that I've enabled auto-login on my Windows 10 OS (no password required on startup or wake). Maybe this skips the part of the webhooks reconnecting?

If it cannot be replicated or fixed, is there a way to make an stream deck action/icon to reconnect to home assistant? That would be a short term solution...

@glnces
Copy link

glnces commented Jun 30, 2022

I think it has to do with the webhooks losing connection on sleep. The connection can be re-established by exiting the stream deck app and opening it again, or rebooting/restarting your home assistant. I have disabled all network power saving features and enabled Wake on LAN, so my network card should not be shutting down on sleep.

The only other difference I have in my setup, is that I've enabled auto-login on my Windows 10 OS (no password required on startup or wake). Maybe this skips the part of the webhooks reconnecting?

If it cannot be replicated or fixed, is there a way to make an stream deck action/icon to reconnect to home assistant? That would be a short term solution...

I think you're exactly right about the webhooks not re-initializing if you have it set to not require a password after sleep. I just changed my windows settings back to require a password after sleep and the Stream Deck worked as expected.

@cgiesche
Copy link
Owner

cgiesche commented Jul 1, 2022

Great finding! Maybe I could add a 2 second-delay before i reestablish the websocket connection (or find out, why the plugin does not automatically retry to establish the connection as intended).

@benji101
Copy link

benji101 commented Jul 4, 2022

Wow! Thank you so much for this! Like I said before, I not only had problems with HA plugin, but also a date widget and the weather one. All of them work perfectly now. I would have prefered to leave auto-login on, but it's a minor issue compared to having to kill and relauch the Stream Deck app all the time.

@ad314159
Copy link
Author

Have you been able to implement the delay, or find out why it was not reconnecting?

@arthurEspooner
Copy link

my PC never goes to sleep or back to the login screen, but after ~5 hours i also experience this issue. every other plugin i use responds properly.

@durcet
Copy link

durcet commented Jan 11, 2023

I have this same issue, but using:

  • Stream Deck Mk1 / app v6.0.2 (17735) / firmware 1.02.007
  • Home Assistant plugin 2.0.1
  • Mac OS 13.0.1

Seemingly overnight (without the laptop going to sleep) connection is lost and won't re-establish without a restart of the Stream Deck app - restarting Home Assistant does not solve it. During this time the entities and actions are still populated, though I presume they're cached or something. Exiting and reopening the Stream Deck app reconnects and functions operate as before.

@Bupher
Copy link

Bupher commented Mar 16, 2023

Figured I'd jump on this train and say I am having the same issues described above. Win 11 (was also an issue in windows 10), without password required for login or wake from sleep.

After hibernation, I have to manually go in and close and re-open the stream deck companion software to re-gain my home assistant connection.

@arthurEspooner
Copy link

@cgiesche fixed the memory leak and i can confirm my stream decks no longer go unresponsive after a certain amount of time. i personally have not seen this issue in ~2 months.

there's also another part to the issue though, because elgato has a known bug where you have to re-plug the USB. i will start to experience delayed commands, especially switching between pages on my XL. takes 3-5 seconds for the page to change when it's typically instant. when you replug the USB (don't even need to restart the app) it goes away and everything is snappy again.
you can see people have talked about this one for years.

it sounds like this thread might me a mixture of these issues.

@Bupher
Copy link

Bupher commented Mar 27, 2023

I found a work around for now, with task scheduler on wake and taskkill.

For some reason, there are multiple processes, but it doesn't seem to matter if you kill it too many times.

taskkill /IM streamdeck.exe
taskkill /IM streamdeck.exe
taskkill /IM streamdeck.exe
taskkill /IM streamdeck.exe
taskkill /IM streamdeck.exe
taskkill /IM streamdeck.exe
taskkill /IM streamdeck.exe
taskkill /IM streamdeck.exe
taskkill /IM streamdeck.exe
taskkill /IM streamdeck.exe
timeout 5
taskkill /IM streamdeck.exe
start "" "C:\Program Files\Elgato\StreamDeck\StreamDeck.exe" --runinbk
exit

@cgiesche
Copy link
Owner

As many things have changed on both sides (plugin and streamdeck app): Does the issue (Lost connection after PC sleep) still occur?

@Bupher
Copy link

Bupher commented Jun 23, 2023

@cgiesche I just disabled my scheduled task and it still does not connect on wake from hibernation (I did try the buttons, they show the yellow warning triangle). Restarting the client still corrects the issue.

Fresh Wake:
image

After Client Restart:
image

@ad314159
Copy link
Author

Yes, the problem has persisted, even after all the latest changes.

My computer is set to auto-login on boot and I believe that this is what is affecting the plugin. There is a service or refresh that is not occurring because I do not have to login after the PC sleeps. I am not familiar enough with Windows or what is occurring to troubleshoot it any further...

To resolve the issue, I have to quit the Streamdeck application and re-launch it after waking the PC each time.

@baggytrowsers
Copy link

Any update on this? I'm still having to relaunch the Streamdeck app every time the PC wakes up (with an auto-login on boot).

@vitruvo
Copy link

vitruvo commented Sep 17, 2023

Ihm having the exact same issue on

  • MacOS 13.5.2 (22G91) (Ventura)
  • MacBook Pro M1 Max
  • Stream Deck MK2 / FW 6.3.1 (18954) / Plugin Version 2.3.1

Doesn't respond after waking up from sleep.
Tried to "save and (re)connect" within the config, but that didn't help.
Restarting Stream Deck solved it.

@LukePetko
Copy link

Having the same issue as well on MacOS Sonoma 14.0

@bgoncal
Copy link

bgoncal commented Nov 24, 2023

Same here, whenever the mac sleeps for a considerably amount of time it requires me to open stream deck and tap reconnect inside the HA tile

@Hessenpower01
Copy link

Same here, even with the updated Plugin

  • Windows 10
  • Streamdeck MK2, FW 1.01.000, SW 6.4.1.19697
  • Plugin 2.4.0

@cgiesche
Copy link
Owner

I am looking into this issue.

cgiesche added a commit that referenced this issue Nov 27, 2023
Fixed #185 (Missleading "optional" hint, reconnect not working)
@cgiesche
Copy link
Owner

https://github.com/cgiesche/streamdeck-homeassistant/releases/tag/2.4.1

(Coming soon(tm) to elgato store, download and install manually to get features now)

@bgoncal
Copy link

bgoncal commented Nov 27, 2023

https://github.com/cgiesche/streamdeck-homeassistant/releases/tag/2.4.1

(Coming soon(tm) to elgato store, download and install manually to get features now)

Installed, I will keep an eye to see if it fixes the issue

@BlomRuben
Copy link

Having a simular issue to those discribed above. After leaving my PC for some time. No sleep and no hibernate, not even locking the screen. The HA plugin goes unresponsive, but still shows static data and no explenation marks. I need to restart the deck app to get it working again. I set up the HA connection external with SSL/WSS and Cloudflare tunnel. I just changed it to internal connection to try if the problem percists. Will keep you updated.

@cgiesche
Copy link
Owner

cgiesche commented Dec 5, 2023

@BlomRuben
Please try this release:

https://github.com/cgiesche/streamdeck-homeassistant/releases/tag/2.4.1

(Coming soon(tm) to elgato store, download and install manually to get features now)

@strausmann
Copy link

I have the same problem with Windows 11. But I'm glad to have just found out about version 2.4.1.
I've just installed it and I'm curious to see if it solves the problem.
Thank you for hopefully fixing this problem after so long.

@cgiesche cgiesche added the bug Something isn't working label Dec 10, 2023
@BlomRuben
Copy link

@cgiesche the new release solved it for me. Thank you!

@cgiesche cgiesche self-assigned this Dec 20, 2023
@cgiesche
Copy link
Owner

Fixed in latest release.

@EDIflyer
Copy link

EDIflyer commented May 5, 2024

Sorry to re-open this issue but just encountered it for the first time today!

Windows 11
Stream Deck software v6.6.0 (20583)
Firmware version v1.02.000
HA plugin v2.4.5

Symptoms seem to be the same as above - after coming out of standby (I and don't have autologin enabled, I need to enter a PIN to unlock the PC) the Stream Deck starts up again and static content is shown (with switch status for a light correct), but then pressing any HA button just shows a yellow exclamation mark with nothing in the Stream Deck logs.

I had thought it was something with my long-access token at first but replaced it with no change. I get green ticks against the server URL (internal IP) and token. I can browse entities OK.

If I then exit the Stream Deck application and re-start it then it works fine again but when I put the PC to standby and wake it back up it stops working again.

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