Hi,
I thought I might share my attempt at remote Shutdown/Restart/Sleep/Hibernate of a windows machine.
I installed a windows program called Airytec Switch Off, I use to schedule a shutdown of my machine on a timer if I need it to run for an hour or two after I go to bed. it can also function as a web server and creates a little web page accessible over LAN and with port forwarding over the net (HTTP). you can also password protect the web page to stop mischevious goblins from playing pranks.
Here is the Setup:
-
Download and install Airytec Switch Off.
-
Setup a task to automatically start the program on login using Task Scheduler Guide
-
Right-click the tray icon and go to options -> remote -> edit web interface settings. This opens another window. click the remote tab and enable a web interface and set a port number. if you are using home assistant remotely (away from home you likely have SSL so you donāt need to forward the port from this program)
-
Click on View Web Interface you can now access this page on any machine over the local network to control your PC.
(you may want to set your firewall to allow this program access to the home network) -
Ok now for the home assistant configuration:
input_select:
pcoptions:
name: PC Power Options
options:
- Restart
- Shutdown
- None
- Sleep
- Hibernate
initial: None
icon: mdi:desktop-tower
shell_command:
shutdown_z800: 'curl -k (url of links from step 4)'
restart_z800: 'curl -k (url of links from step 4)'
sleep_z800: 'curl -k (url of links from step 4)'
hibernate_z800: 'curl -k (url of links from step 4)'
automation:
- alias: z800_restart
trigger:
platform: state
entity_id: input_select.pcoptions
to: "Restart"
action:
- service: shell_command.restart_z800
- alias: z800_shutdown
trigger:
platform: state
entity_id: input_select.pcoptions
to: "Shutdown"
action:
- service: shell_command.shutdown_z800
- alias: z800_sleep
trigger:
platform: state
entity_id: input_select.pcoptions
to: "Sleep"
action:
- service: shell_command.sleep_z800
- alias: z800_hibernate
trigger:
platform: state
entity_id: input_select.pcoptions
to: "Hibernate"
action:
- service: shell_command.hibernate_z800
In my setup, I also get a notification on telegram via IFTTT when any of these actions are performed.
And there you have it⦠super easy and very useful.
āIām sorry I wrote you such a long letter; I didnāt have time to write a short one.ā
Blaise Pascal