Turn off pc in automation

Good morning,

Currently when my smart samsung TV turns off, at a certain time in the evening (before going to sleep :unamused: :unamused:), I have an automation that turns off all my lights and other things.

I would also like to turn off my mini PC (“properly”) connected to my TV in this automation.

How can I do it?

THANK YOU

Which OS does it run?

windows 11

actually I could use a SwitchBot Smart Switch on the power button but I think it’s not recommended
???

I use this for win 10, it should work for win 11.

I made a switch for my PC so I can turn it on or off (sleep):

switch:
  - platform: wake_on_lan
    mac: "<redacted>"
    host: 10.1.1.2
    name: PC
    turn_off:
      service: shell_command.turn_off_pc
shell_command:
  turn_off_pc: 'curl -k http://10.1.1.2:8000/?action=System.Sleep'

To use that command you need to install this on your PC:

https://www.airytec.com/en/switch-off/

and if you want a full shutdown rather than sleep then change the shell command to use ?action=System.Shutdown instead of ?action=System.Sleep'

Not sure if WoL works if the PC is shutdown though so there may be no point going to all the trouble of making the switch. Just use the shell command.

Does this shell command stop Windows properly and then power off the PC?

thanks

Yes.

last version : 3.5.1 (26 janv. 2015) ??

os

  • Windows 2000
  • Windows XP
  • Windows 2003
  • Windows Vista
  • Windows 2008
  • Windows 2008 R2
  • Windows 7
  • Windows 8
  • Windows 8.1
  • Windows 2012
  • Windows 2012 R2

??

ok for win 11

thanks

I’d assume so. It works on W10.

ok i will try 


What do you think about the solution https://github.com/hass-agent/HASS.Agent ?

thanks

I just tested ‘switch off’ and it works perfectly.

:+1:

but how to launch this task from ha ??

I don’t see in the shell_command the call of the task ‘switch off’ ??

thanks

Huh. I already have that installed to monitor memory and CPU. Just tried the sleep button. It works. No need for Airytec SwitchOff. I can uninstall it.

Dashboard button action or automation.

It just the action, like I showed above:

Or in the new syntax:

action: shell_command.turn_off_pc

i made your solution but 


time out 


action: shell_command.turn_off_pc
data: {}

Commande en cours d’exĂ©cution expired : curl -k http://192.168.0.243:8000/?action=System.Shutdown, after : 60 secondes


configuration

shell_command:
turn_off_pc: ‘curl -k http://192.168.0.243:8000/?action=System.Shutdown’


in task bar:

thanks for your support