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: Sleep command actually hibernates the PC #210

Open
2 of 4 tasks
felipecrs opened this issue Dec 27, 2024 · 2 comments
Open
2 of 4 tasks

Bug: Sleep command actually hibernates the PC #210

felipecrs opened this issue Dec 27, 2024 · 2 comments
Labels
bug Something isn't working enhancement New feature or request

Comments

@felipecrs
Copy link

Describe the bug
The Sleep command actually hibernates the PC, which is very different and takes a lot more time to recover.

To Reproduce
I believe this is kinda self-explanatory, but:

Add a button like such:

image

Then press it from Home Assistant. Instead of sleeping, the computer will hibernate. At least mine does.

Expected behavior
To sleep, not hibernate.

Screenshots
N/A

Misc info (please complete the following information):

  • Windows build (ideally screenshot/info of winver.exe output):

image

  • Windows' UI language: Portuguese (Brazil)
  • HASS.Agent version: 2.1.0

Please check what's applicable (multiple answers possible):

  • Installed via installer
  • Installed manually
  • Problem occurs in HASS.Agent
  • Problem occurs in Satellite Service

Additional context
Sleeping the PC works fine through PowerShell using this:

# load assembly System.Windows.Forms which will be used
Add-Type -AssemblyName System.Windows.Forms

# set powerstate to suspend (sleep mode)
$PowerState = [System.Windows.Forms.PowerState]::Suspend;

# do not force putting Windows to sleep
$Force = $false;

# so you can wake up your computer from sleep
$DisableWake = $false;

# do it! Set computer to sleep
[System.Windows.Forms.Application]::SetSuspendState($PowerState, $Force, $DisableWake);

Logs
I could not find anything relevant in the logs.

@felipecrs felipecrs added the bug Something isn't working label Dec 27, 2024
@amadeo-alex
Copy link
Collaborator

Hmm, I'm not the author of that specific piece of code but:
q0Rt2B

It is interesting however that the winforms command works properly for you - I'll do some testing to see if it can be used but the SleepCommand is also "available" for satellite service where winforms might not work properly due to missing user context.

@amadeo-alex amadeo-alex added the enhancement New feature or request label Dec 29, 2024
@felipecrs
Copy link
Author

Oh. I wonder how come I completely missed that.

But I suppose this command can be refactored to simply call that PowerShell command, which works (even when called from Hass Agent using the PowerShell method).

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

No branches or pull requests

2 participants