Remote Shutdown/Restart/Sleep/Hibernate PC

OK so, assuming your HA is on Raspberry PI logon to it via SSH and run the same command:
(you should first switch to virtual env)
sudo su -s /bin/bash homeassistant
source /srv/homeassistant/homeassistant_venv/bin/activate or source /srv/homeassistant/homeassistant/bin/activate depending on your install options.

and then paste the command and in case there is any error please copy it to https://hastebin.com/ and paste the link here.

I guess you would have more luck asking for help on HA discord chat https://discordgg/c5DvZ4e. Itā€™s way more responsive :slight_smile:

Hi there

sorry for the very late reply (life getā€™s in the way sometimes)

i have been looking at my config and comparing it what you have and i honestly canā€™t find a reason it wouldnā€™t work, especially if http://192.168.0.141:8909/?action=System.Shutdown works in the browser.

Does it work if you SSH into the Raspberry Pi and type the command

curl -k http://192.168.0.141:8909/?action=System.Shutdown

Thanks

Great job.

I tried Airytec, but I never made it work.

Instead I made something similar, by plugging my computer into a Wemo Switch, I can turn on through HASS UI and my Echo. In addition, i created a cmd switch, that remotely shutdown my computer, when triggered through hass UI or my Echo. after the power consumption is at its lowest, the Wemo Switch turns off.

thatā€™s a cool way to do itā€¦ how did you make the cmd switch? does the wemo turn off the power if your machine goes to sleep? or did you have to disable sleep mode?

You need to remove the parentheses

Season Greetings guys.

Everything works as expected except I donā€™t know what to put in the shell command if enable password protection on the web interface. Any advice?

@bilalY i cant use this project with hass.io right?

Hi,

I donā€™t think itā€™s possible with Airytec Switch Off, for that to work I guess you would need to put in your password into the URL, similar to how IP cameras can include password and username in rtsp linkā€¦ there may well be software out there that supports a feature like this but I have never looked. the other solution might be to come up with some script that can inject the username and password for you but again i have no experience in this.

Hi, Iā€™m not sure I understand your question. your link just goes to the home assistant website.

@bilalY i ask you if your project run on hass . io did you have hassbian? I use hass. io , hass.io doesnt have sudo commands.

oh, i see. ye Iā€™ve only ever used hassbian so I have no idea about hassio. sorry, i canā€™t be of much help to you.

Hey thanks for the input, it works like a charm.

For any1 interested, i have combined it with a WOL command on a switch:

switches.yaml:

  - platform: wake_on_lan
    name: My PC
    mac_address: "00-00-00-00-00-00"
    host: xxx.xxx.xxx.xxx
    icon: mdi:desktop-classic
    turn_off:
      service: shell_command.sleep_my_pc

Problem arised when I tried adding further functionality, i.e. turn off the monitors (with the help of nircmd.exe)

The predefined commands of the airytec thingy (say the preinstalled one that launches calculator) do work when calling them from the tray icon but do not work from the web interface that airytec is providing nor when calling them from HA.

They do create a process (calc.exe) in the task manager but the actual window never appears.

Problem is also described here

I realise this is probably a windows problem but, got any ideas?

Hi to all.
If you have any problem (like curl not works or similar) try to force manually on Windows Firewall (if enabled) app rules (Local and not) add the executable path (ex. C:\Program Files\Airytec\Switch Off\swoff.exe ) and try to modify config.yaml without () after curl .
It works for me!

c ya

Donā€™t think my issue is on curl, the command runs but I only get the calculator on windows as a process and k thing pops up.
I think itā€™s some issue of airytech

Hi,

it works on hass.io as well.
Generally, shell commands work on SSH for hass.io, only likes of sudo etc. donā€™t.

Back to hass.io, I followed the instruction, set up password for Airytec in Options, I couldnā€™t see View web interface link otherwise. Created firewall rule for port 8000 (not sure if necessary tho).
Left automation: code part as it is, and for shell command:

shutdown_z800: 'curl -u User:password -k http://yourip:8000/?action=System.Shutdown'

etc.

Works like a charm.

Many thanks to bilalY.

3 Likes

But I have the next problem. If I turn off the PC using Airytec (via hass.io) then my PC (Win 10) will not turn on via WOL, only turns on with a physical button. If I turn off the PC using the start menu, then my PC (Win 10) will turn on via WOL.

I found I had this problem also but my friend doesnā€™t have this issue, itā€™s possible it is somthing to do with the WOL implementation in the system itself. To be honest I never shut down using airytec. If Iā€™m away from home I use WOL to turn on the machine then I access it with TeamViewer which I have setup to autostart. When I am done I perform a shutdown from the start menu. the whole purpose for me with this is the ability to reboot the machine if there are any problems with remote access caused by a crash etc.

Thank you bilalY for the answer. At the moment I use this same circuit (with Teamviewer), but I wanted automation. Now, I use hibernation instead of turning off (this is for automation).

Hiā€¦I tried the OP method and it did not work. I have to add program switchoff into the Windows Firewall to allow its access; then it works smoothlyā€¦thanks a lot.

Hello guys!

Have you tried this app instead of Airytec? A lot more capable and flexibleā€¦

https://iotlink.gitlab.io/

Thanks!

6 Likes