streamdeck-homeassistant icon indicating copy to clipboard operation
streamdeck-homeassistant copied to clipboard

Lose connection to HA after PC Sleep

Open ad314159 opened this issue 4 years ago • 14 comments

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

ad314159 avatar Jan 08 '22 14:01 ad314159

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.

cgiesche avatar Jan 08 '22 23:01 cgiesche

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

ad314159 avatar Jan 09 '22 17:01 ad314159

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 avatar Jan 12 '22 00:01 ad314159

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.

ad314159 avatar Jan 18 '22 22:01 ad314159

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).

benji101 avatar Apr 01 '22 12:04 benji101

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.

snadams avatar Jun 13 '22 04:06 snadams

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.

glnces avatar Jun 15 '22 06:06 glnces

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 :(

cgiesche avatar Jun 15 '22 07:06 cgiesche

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.

benji101 avatar Jun 15 '22 12:06 benji101

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...

ad314159 avatar Jun 16 '22 21:06 ad314159

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.

glnces avatar Jun 30 '22 17:06 glnces

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).

cgiesche avatar Jul 01 '22 12:07 cgiesche

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.

benji101 avatar Jul 04 '22 14:07 benji101

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

ad314159 avatar Sep 12 '22 17:09 ad314159

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.

arthurEspooner avatar Jan 11 '23 14:01 arthurEspooner

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.

durcet avatar Jan 11 '23 17:01 durcet

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.

Bupher avatar Mar 16 '23 07:03 Bupher

@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.

arthurEspooner avatar Mar 20 '23 17:03 arthurEspooner

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

Bupher avatar Mar 27 '23 02:03 Bupher

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

cgiesche avatar Jun 22 '23 19:06 cgiesche

@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

Bupher avatar Jun 23 '23 04:06 Bupher

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.

ad314159 avatar Jun 26 '23 15:06 ad314159

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).

baggytrowsers avatar Aug 17 '23 21:08 baggytrowsers

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.

vitruvo avatar Sep 17 '23 17:09 vitruvo

Having the same issue as well on MacOS Sonoma 14.0

LukePetko avatar Nov 19 '23 17:11 LukePetko

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

bgoncal avatar Nov 24 '23 12:11 bgoncal

Same here, even with the updated Plugin

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

Hessenpower01 avatar Nov 27 '23 13:11 Hessenpower01

I am looking into this issue.

cgiesche avatar Nov 27 '23 13:11 cgiesche

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)

cgiesche avatar Nov 27 '23 14:11 cgiesche

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

bgoncal avatar Nov 27 '23 15:11 bgoncal