sleevezipper / hass-workstation-service

Provide useful sensors and services from your workstation to Home Assistant.
Apache License 2.0
611 stars 54 forks source link

Dedicated Sleep Command Options and more #31

Open regoras opened 3 years ago

regoras commented 3 years ago

I saw the discussion on Reddit regarding sleep commands and the issues that come with hibernation. A little Google-fu yielded this Superuser discussion and a Microsoft tool that can be utilized for a proper dedicated sleep command, but it would require users to install a dependency (psshutdown.exe).

https://superuser.com/questions/42124/how-can-i-put-the-computer-to-sleep-from-command-prompt-run-menu/395497#395497

https://docs.microsoft.com/en-us/sysinternals/downloads/psshutdown

The command seems to only work for me when including the accepteula portion: psshutdown -d -t 0 -accepteula

There's also the potential for further extensibility with pstools.

sleevezipper commented 3 years ago

Thanks for creating an issue!

A way to depend on other software in an intuitive way would be pretty nice! I've also been thinking about some sort of add-on implementation so people can extend this application easily.

silverl commented 3 years ago

FYI for the sysinternals suite of power tools, they all require you to accept an EULA on first invocation only (in my experience). If it's a GUI tool, the tool presents a GUI dialog to accept the EULA, then sets a registry key. If you invoke the command with the -accepteula argument, I believe you only need to do so the first time, and it should result in the same registry key getting set as using the GUI.

mkono87 commented 2 years ago

Im not developer but is it worth seeing how IotLink is doing it? https://gitlab.com/iotlink/iotlink

amaisano commented 2 years ago

psshutdown requires a bash with admin privileges, which HASS W cannot (?) do.

NirSoft's nircmd.exe standby command works however, and doesn't need admin privileges (so can be created in HASS W). This is what I'm currently using.

There is a UserDLL windows-native method for suspend as well, but it's very complicated and has a risk of failing. It may also need elevated privileges.