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

[BUG] Power state not updated at wake up #370

Open
fabricemrchl opened this issue Dec 18, 2024 · 4 comments
Open

[BUG] Power state not updated at wake up #370

fabricemrchl opened this issue Dec 18, 2024 · 4 comments
Labels
bug Something isn't working

Comments

@fabricemrchl
Copy link

Go Hass Agent Version
Go Hass Agent: v10.5.1

Describe the bug
Power state is not update in Home Assistant at wake up from Suspsended mode.
go-hass-agent try to update sensor.state but network is not yet ready after wake up so there is an error. Even after network ready go-hass-agent do not try again to update sensor state in error.
Result is Home Assistant does not receive update about sensor state that change only once just after wake up and before network is up.

In log file attached :

  • Line 45 : power_state is set to "Suspended"
  • Line 46 : PC is wake up and some error appear due to network not yet up
  • Line 47 : Power stateupdate is in error, still no network
  • Line 92 : Network is up, sensore state is updated but no retry on previous error

I automate an action at PC wake up on Home Assistant. Because of this issue it does work.

Issue seems appear if PC is une suspended mode for a long time. If I wake up my PC 2 minutes after suspended mode power state is updated.

To Reproduce
Steps to reproduce the behaviour:

  1. Do suspend your PC
  2. Wait a long time
  3. Wake up PC
  4. See error = power state not updated

Expected behaviour
Power state update after PC wake up. 2 options maybe, wait for network before sending any sensor.state update, or retry previous sensor.state update that failed. Especially sensor.state that change little like Power State.

Screenshots
N/A

Logs
A log will be very helpful to look into this bug report. To get the log:
go-hass-log.txt

Desktop (please complete the following information):

  • OS: Linux Mint
  • Distribution : Mint
  • Version : 22
@fabricemrchl fabricemrchl added the bug Something isn't working label Dec 18, 2024
@joshuar
Copy link
Owner

joshuar commented Dec 20, 2024

Hey thanks for trying out Go Hass Agent and reporting this bug!

Also thanks for the detailed walkthrough, I can clearly see the problem. For all sensor updates, I don't do any retries if an update fails to get sent to Home Assistant. In nearly all cases, this is fine, as you'll get new data on the next poll. However, in this case, you definitely do want to send the existing update otherwise the power state is wrong as you've discovered.

I'll have to have a think about how I can implement this. I'll leave this bug open as a tracker and I'll update when I've got a fix.

Cheers.

@joshuar
Copy link
Owner

joshuar commented Dec 22, 2024

Hey there, I've spent some time looking at this over my weekend and I believe b103679 should fix this issue. At least in my testing, after suspend my power state sensor is updating correctly. This will go into the next release 🎉

@fabricemrchl
Copy link
Author

Hi,
Good news, thank you.
I will try to build it to test before release.
I hope the exponential mechanism will not increase too much the delay. If so the automation on home assistant will be too late.

Another way could be to wait for an active connection before sending requests, but I don't know if there is a reliable way to detect it.

@fabricemrchl
Copy link
Author

All good today, multiple wake up and sensor was updated as expected.
I will keep this version few days to be sure.

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