How to shutdown a Windows 10 PC ?
-
@cw-kid I have a small utility running on my PC for the very same reason, that's receiving MQTT messages to shutdown automatically. HASS has a similar 3rd party app to accomplish the same: https://github.com/LAB02-Research/HASS.Agent
Easy to integrate under MSR.
-
Thanks for the replies !
I am not using Home Assistant or MQTT however.
Regarding the audio I just had a look at the back of the Mini-PC and I cannot see any other audio output ports. I will have to find its user manual not even sure what make and model it is.
The sticker on it says SEI10-G might be the same as this one here on Amazon.
-
Looking at the photos of it on Amazon there is a head phone 3.5mm jack on the front of it and two HDMI on the back of it.
-
APC used to have a free utility which you might be able to re-purpose.
C
-
@cw-kid said in How to shutdown a Windows 10 PC ?:
Thanks for the replies !
I am not using Home Assistant or MQTT however.HASS is not really needed, but MQTT is mandatory because it's used to exchange messages. The alternative is something running an HTTP endpoint on the PC, but from a security point of view that's bad, but doable.
-
OK turns out it's comparatively trivial to do it from Linux (was pretty sure it was. So you should be able to execute this. Bit of a faff for set up but...
Actually reading further, looks like there's some simpler options installing Cygwin or an SSH server and just SSHing in
C
-
OK thanks I will take a read and report back.
-
I updated this PC to Windows 11 and installed OpenSSH Server on it. I was then able to login to it directly via Putty on my other Windows 10 laptop, I was prompted for the username and password and I could then issue a
shutdown /p
command and it did then shutdown the Mini-PC.I then tried to add my Vera Plus public key on to the Windows 11 PC so that Vera can ssh directly to it with no username and password prompt etc. However its not working I get this error every time.
ecdsa-sha2-nistp256 host key mismatch for 192.168.1.47 !
192.168.1.47 being the Windows 11 OpenSSH Server
I created an authorized_keys file on the Windows 11 PC in this location:
C:\Users\myusername\.ssh
And in the authorised_keys file I pasted in the Vera Plus pubic key.
I also followed the instructions on this article here to enable "Public key authentication" on the OpenSSH Server on the Windows 11 PC.
Then reading this Microsoft article it suggested if my windows user is in the administrators group I need to instead create a
administrators_authorized_keys
file in C:\ProgramData\ssh\So I tried that but I still get the host key mismatch error when I connect to the Vera Plus via putty and then tried to ssh to the Windows 11 PC.
-
I think you need your public key stored on the Vera. Or possibly a public key that matches the username you're using.
There's also an sshd-copy-id command which I found way more reliable than trying to edit authorised keys files. I'd probably use that, then rename the file if needed.
C
-
toggledbitswrote on Nov 2, 2022, 1:57 PM last edited by toggledbits Nov 2, 2022, 9:57 AM
If the Windows PC was previously known to the Vera before your upgrade, it's likely that the SSH key was regenerated on the Windows PC side when you did the upgrade, so the Vera SSH has the old host key. You can remove it from the
known_hosts
file on the Vera side.That may not be the only problem you run into, though. Of late, many newer SSH clients have removed weaker host key algorithms and key exchange algorithms, so connecting to the ancient, rotting carcasses of these old Veras presents the SSH peer with a set of options it doesn't want to use, and the key exchange fails. That's a bit more complicated to fix...
-
I always struggle with this type of stuff. Patrick helped me in the past on this Vera forum thread here.
On that old post I wanted my Vera Plus to be able to ssh into my Raspberry Pi with no password prompt.
I could then create MSR rules that instruct Vera to run a command like this to say reboot the Raspberry Pi etc.
os.execute("ssh pi@192.168.1.101 sudo reboot")
-
cw-kidreplied to toggledbits on Nov 2, 2022, 2:01 PM last edited by cw-kid Nov 2, 2022, 10:02 AM
@toggledbits said in How to shutdown a Windows 10 PC ?:
If the Windows PC was previously known to the Vera before your upgrade, it's likely that the SSH key was regenerated on the Windows PC side when you did the upgrade, so the Vera SSH has the old host key. You can remove it from the known_hosts file on the Vera side.
The Mini-PC was not known to the Vera before. I updated to Windows 11 and then install OpenSSH on the Windows 11 PC.
Before that I did nothing with Vera and the Mini-PC running Windows.
Oh I think I see what might be happening now. Looking in the known_hosts I already have an entry for the static LAN IP address of the Mini-PC but that is for Linux Debian on the Mini-PC.
Before when I was messing about with Ezlo Softhub I setup a dual boot on the Mini-PC for Windows 10 and Debian Linux.
Guess I can't have two known hosts for the same IP address but different OS's.
-
Well the keys won't match so no. Edit known-hosts on the Vera and delete the entry for that IP
C
-
OK let me try that then.
-
Its working now !
In Putty connected to my Vera Plus I ran a shutdown command to the Windows 11 PC it then said:
Host '192.168.1.47' is not in the trusted hosts file.
I hit Y to continue and Vera has just shutdown the Windows 11 Mini-PC via SSH.
Thanks.
-
OK just setup the rest of my MSR rule now with a Reset reaction, that gets the Vera Plus to run a LUA / os.execute shutdown command sent to the Windows 11 PC.
So now when I start my Logitech Harmony activity for the Windows Games PC, MSR triggers the rule and gets Vera to send a WOL packet to the PC to wake it up.
And when I end the Harmony activity the reset reaction in the MSR rule gets Vera to shutdown the PC.
I even managed to get my Harmony Elite remote to launch RetroArch or Steam via buttons on the LCD screen and I also added a ALT+F4 button to exit the Windows apps.
Next thing to figure out is how to split out the HDMI audio to a pair of PC speakers.
Thanks.
-
Neat!
C
-
14/21