Shutting your computer down through HA.

I have added the Shutdown command to HASS Agent and my Home Assistant sees the button of the shutdown, but for some reason I am unable to shut my computer down through Google Home. I have WOL enabled and I am able to start my computer through Google Home and HA. Its a WOL Switch with the name of my Desktop.
Solution:
```yaml - platform: wake_on_lan mac: mac_address host: ip name: "My PC Power"...
Jump to solution
106 Replies
DrR0x
DrR0x6mo ago
Have you connected the home assistant shutdown button to google home? WoL is one directional, only starts
Dutchbear
DutchbearOP6mo ago
In the past before I did a clean install on my computer I was able to wake the computer up and shut the computer down with the same entity. I rather have that again to have 1 button for waking it and shutting it down.
DrR0x
DrR0x6mo ago
NGL idk how that would work, was it a WoL entity in HA? that triggered shutdown?
Dutchbear
DutchbearOP6mo ago
Yes. Switch.(computername)_wol was the entity name. That one currently wakes the computer up.
DrR0x
DrR0x6mo ago
WoL as in the HA integration? how does that single entity connect with a separate hass.agent entity?
Dutchbear
DutchbearOP6mo ago
I don't remember how that was configured before the clean install. I am pretty new to HA, but I know it did work with 1 button, but I don't remember how.
DrR0x
DrR0x6mo ago
What integration was the entity attached to?
Dutchbear
DutchbearOP6mo ago
MQTT I think It also is connected with MQTT currently. The shutdown control is in the list there, but I want if its possible merge it with the WOL switch.
DrR0x
DrR0x6mo ago
Merging 2 integrations isn't really possible, however you can create helper switches/groups that could do this
Dutchbear
DutchbearOP6mo ago
Yeah I was trying to mess with a help like saying if press switch WOL on, then execute this and if you press off then execute this. But I am having trouble configuring that.
DrR0x
DrR0x6mo ago
I think the best way would be 2 automations with a helper toggle
Dutchbear
DutchbearOP6mo ago
Hmm okay. I need to see then how I can configure this since I am new to Home Assistant.
DrR0x
DrR0x6mo ago
In the integrations tab you can add a new toggle helper. Then create 2 automations for it turning on and off, do the relevant actions for each toggle state
Dutchbear
DutchbearOP6mo ago
So create 1 toggle helper for switching on/off and then 2 automations?
DrR0x
DrR0x3w ago
Did this work?
Dutchbear
DutchbearOP3w ago
It did not, but I didn't really think about it anymore after it didn't work
DrR0x
DrR0x3w ago
Do you still want to get this working?
Dutchbear
DutchbearOP3w ago
if it can yes
DrR0x
DrR0x3w ago
Can you send me your WoL config? sanitise if needed and use codeblocks, put 3
`
`
at top and bottom
Dutchbear
DutchbearOP3w ago
I can do that tonight (local time)
DrR0x
DrR0x3w ago
timezone?
Dutchbear
DutchbearOP3w ago
CET/CEST
DrR0x
DrR0x3w ago
<t:1737136800:R>?
Dutchbear
DutchbearOP3w ago
Sure.
DrR0x
DrR0x3w ago
Okay, ill have a look at it tmr, Aussie timezone makes it quite annoying to do stuff with people on the other side of the world
Dutchbear
DutchbearOP3w ago
Alright Only thing I could find really is this:
- platform: wake_on_lan
mac: (Removed for privacy)
host: (Removed for privacy)
name: (Removed for privacy)
- platform: wake_on_lan
mac: (Removed for privacy)
host: (Removed for privacy)
name: (Removed for privacy)
- platform: wake_on_lan
mac: (Removed for privacy)
host: (Removed for privacy)
name: (Removed for privacy)
- platform: wake_on_lan
mac: (Removed for privacy)
host: (Removed for privacy)
name: (Removed for privacy)
Don't really know where else to look. Maybe I have to reconfigure it completely, but I am not that experienced with HA
DrR0x
DrR0x3w ago
These both hass.agent?
Dutchbear
DutchbearOP3w ago
No idea tbh a friend of mine sent me it and told me to put in a .yaml file
DrR0x
DrR0x3w ago
Ah okay, how many hass.agent PCs do you have?
Dutchbear
DutchbearOP3w ago
1 the second platform is the RP that is hosting HA
DrR0x
DrR0x3w ago
Okay, so how did you edit .yaml? Do you have the file editor add on?
Dutchbear
DutchbearOP3w ago
Yes studio code server
DrR0x
DrR0x3w ago
Okay, can you show me up a few lines of the snippet U sent? Specifically whether it's a button or a switch
Dutchbear
DutchbearOP3w ago
The text I shared is a .yaml file called scripts and then the configuration.yaml file has this:
# Wake on Lan
wake_on_lan:
# Wake on Lan
wake_on_lan:
DrR0x
DrR0x3w ago
Can you show me a scrshot of the script you use to turn it on through HA
Dutchbear
DutchbearOP3w ago
Let me see if I can find it Found it I think
input_boolean:
(PC name)_lock:
name: Lock
icon: cil:lock

switch:
- platform: template
switches:
(PC name):
friendly_name: (PC name)
icon_template: mdi:desktop-classic
value_template: >
{{ is_state('switch.(PC name)_wol', 'on') }}
turn_on:
- service: switch.turn_on
data: {}
target:
entity_id: switch.(PC name)_wol
turn_off:
if:
condition: state
entity_id: input_boolean.(PC name)_lock
state: "off"
then:
service: button.press
target:
entity_id: (PC name)_shutdown_2
input_boolean:
(PC name)_lock:
name: Lock
icon: cil:lock

switch:
- platform: template
switches:
(PC name):
friendly_name: (PC name)
icon_template: mdi:desktop-classic
value_template: >
{{ is_state('switch.(PC name)_wol', 'on') }}
turn_on:
- service: switch.turn_on
data: {}
target:
entity_id: switch.(PC name)_wol
turn_off:
if:
condition: state
entity_id: input_boolean.(PC name)_lock
state: "off"
then:
service: button.press
target:
entity_id: (PC name)_shutdown_2
DrR0x
DrR0x3w ago
can you show me a scrshot of the switch.pc-name-wol? in the dashboard i mean
Dutchbear
DutchbearOP3w ago
What do you mean exactly?
DrR0x
DrR0x3w ago
No description
Dutchbear
DutchbearOP3w ago
ah okay
Dutchbear
DutchbearOP3w ago
No description
DrR0x
DrR0x3w ago
Click 3 dots and 'device info'
Dutchbear
DutchbearOP3w ago
It only says "related"
DrR0x
DrR0x3w ago
is there any mention of switch in configuration.yaml?
Dutchbear
DutchbearOP3w ago
switch: !include switch.yaml is there and in switch.yaml is the file where this is:
- platform: wake_on_lan
mac: (Removed for privacy)
host: (Removed for privacy)
name: (Removed for privacy)
- platform: wake_on_lan
mac: (Removed for privacy)
host: (Removed for privacy)
name: (Removed for privacy)
- platform: wake_on_lan
mac: (Removed for privacy)
host: (Removed for privacy)
name: (Removed for privacy)
- platform: wake_on_lan
mac: (Removed for privacy)
host: (Removed for privacy)
name: (Removed for privacy)
DrR0x
DrR0x3w ago
ah okay sorry, was confused by ur earlier messaging mentioning these were scripts. This is almost done then, let me just give you the snippet to add to the pc
Solution
DrR0x
DrR0x3w ago
- platform: wake_on_lan
mac: mac_address
host: ip
name: "My PC Power"
turn_off:
service: button.press
target:
entity_id: button.my_pc_shutdown
- platform: wake_on_lan
mac: mac_address
host: ip
name: "My PC Power"
turn_off:
service: button.press
target:
entity_id: button.my_pc_shutdown
Sorry for the delay, this is my config
DrR0x
DrR0x3w ago
WoL will automatically maintain status through pinging ip and it will turn on via mac and off via turn_off action, e.g if you want to be able to turn off the RP you could send it a shell command poweroff.
Dutchbear
DutchbearOP3w ago
And I need to put that in switch.yaml right?
DrR0x
DrR0x3w ago
yeah, specifically the turn_off and below should be copied to ur pc
Dutchbear
DutchbearOP3w ago
Alright
Dutchbear
DutchbearOP3w ago
Where this is placed. It says the error:
No description
Dutchbear
DutchbearOP3w ago
service: switch.turn_on and service: button.press is having that error
DrR0x
DrR0x3w ago
oh do you use the locking funcitonality? because you can delete that script
Dutchbear
DutchbearOP3w ago
I can delete this completely?
DrR0x
DrR0x3w ago
yep
Dutchbear
DutchbearOP3w ago
Alright
DrR0x
DrR0x3w ago
the WoL covers it all, except for the lock thing it will only do whatever you select in the turn_off action. Could be lock, shutdown, even change volume
Dutchbear
DutchbearOP3w ago
Developer tools says this: Invalid config for 'wake_on_lan' from integration 'switch' at switch.yaml, line 12: 'service' is an invalid option for 'switch.wake_on_lan', check: service Invalid config for 'wake_on_lan' from integration 'switch' at switch.yaml, line 13: 'target' is an invalid option for 'switch.wake_on_lan', check: target Invalid config for 'wake_on_lan' from integration 'switch' at switch.yaml, line 14: 'entity_id' is an invalid option for 'switch.wake_on_lan', check: entity_id
DrR0x
DrR0x3w ago
you have turn_off right?
Dutchbear
DutchbearOP3w ago
Its in the script. I copied your text and changed it to my things Or is turn_off like a thing I need to install?
DrR0x
DrR0x3w ago
by script you mean switch.yaml?
Dutchbear
DutchbearOP3w ago
Yes I copied your text and replaced my thing in switch.yaml
DrR0x
DrR0x3w ago
HA version?
Dutchbear
DutchbearOP3w ago
Core: 2025.1.2 Supervisor: 2024.12.3 Operating System: 14.1
DrR0x
DrR0x3w ago
Okay try putting this in configuration.yaml, just for testing
wake_on_lan:

switch:
- platform: wake_on_lan
mac: mac_address
host: ip
name: "My PC Power"
turn_off:
service: button.press
target:
entity_id: button.my_pc_shutdown
wake_on_lan:

switch:
- platform: wake_on_lan
mac: mac_address
host: ip
name: "My PC Power"
turn_off:
service: button.press
target:
entity_id: button.my_pc_shutdown
And remove the one from switch.yaml
Dutchbear
DutchbearOP3w ago
I now get multiple things: Missing property "switches" Bad identation of a mapping entry
DrR0x
DrR0x3w ago
tf comment out, put a # in front of anything related to switches and wake_on_lan except the code i just sent oh, i messed up the indentation somehow, copy it again
Dutchbear
DutchbearOP3w ago
The errors are gone now Should I keep it in configuration.yaml?
DrR0x
DrR0x3w ago
just test it first, turn pc off and then back on
Dutchbear
DutchbearOP3w ago
Alright Tested it. Turning it on works fine as it did before, but turning it off still doesn't work But google does say "Alright turning computer .... off" but does nothing
DrR0x
DrR0x3w ago
what if you manually trigger the button.my_pc_shutdown, from the HA interface?
Dutchbear
DutchbearOP3w ago
I will test that When I switch it to off it does nothing. Not getting a warning or something saying "your pc is about to shutdown"
DrR0x
DrR0x3w ago
send me a scrshot of your hass.agent commands config
Dutchbear
DutchbearOP3w ago
No description
DrR0x
DrR0x3w ago
is the shutdown command a button or switch?
Dutchbear
DutchbearOP3w ago
Button The WOL is a switch
DrR0x
DrR0x3w ago
okay try clicking the button in HA just need to ensure the shutdown is working
Dutchbear
DutchbearOP3w ago
Just says this
No description
Dutchbear
DutchbearOP3w ago
Can't press like a switch to turn it on or off
DrR0x
DrR0x3w ago
okay remove it from HASS.Agent, then check if it stills hows under mqtt then re-add it
Dutchbear
DutchbearOP3w ago
Alright removed it and gonna wait until its no longer under mqtt Alright re added it and its back I can however now press it It says "press" next to the name of the button
DrR0x
DrR0x3w ago
just try the switch then the WoL switch
Dutchbear
DutchbearOP3w ago
Do I need to change the script thing to the new shutdown name?
DrR0x
DrR0x3w ago
yes, if you changed it
Dutchbear
DutchbearOP3w ago
Alright Hmm when I use the WOL switch it still doesn't say a warning message
DrR0x
DrR0x3w ago
and doesn't shutdown the pc? try the button then if that doesn't work then somethings wrong with hass.agent
Dutchbear
DutchbearOP3w ago
Button works got the message My pc is shutting down in a bit
DrR0x
DrR0x3w ago
try restarting home assistant
Dutchbear
DutchbearOP3w ago
WIll do just turned on my pc again It works now through Google! Just testing if it turns on too since that didn't work just now Alright so my shutdown works, but turning it on doesn't work anymore? Its unavailable now. The normal switch.name) is available, but only shutdown works
DrR0x
DrR0x3w ago
I mean on shouldn't have changed, Mac address the same? Haven't switched network interface? Wifi to ethernet? Check your logs to see if there's anything about it
Dutchbear
DutchbearOP3w ago
Will do tomorrow since its now midnight So I added a integration called Wake on Lan which created a button and through Home assistant it works, but not through Google Home. I copied that script and changed the entity ID and changed turn_off to turn_on, but apparantly turn_on is not a thing or is it called different?
DrR0x
DrR0x3w ago
The bit I sent you is config to use the in built wake on lan integration Ie, not hacs Switch, declares it's a switch. Wake_on_lan declares it to use wake on lan integration Mac is for turning on, host and name are for checking status Turn off is for turning off
Dutchbear
DutchbearOP3w ago
Weird. The boot up part doesn't work, but the turn off part does work
DrR0x
DrR0x3w ago
Means integration is working, but magic packet isn't, anymore logs have anything?
Dutchbear
DutchbearOP4d ago
Nop Problem is solved. Out of nowhere a new entity was made automatically of my pc and now both WOL and shutdown works
DrR0x
DrR0x4d ago
just to help people in future could you send a screenshot of the entity
Dutchbear
DutchbearOP4d ago
Sure:
No description
No description
DrR0x
DrR0x4d ago
Is this the one created from our config? WoL doesn't do autodiscovery afaik, so you must have configured it
Dutchbear
DutchbearOP4d ago
I think so? I haven't configured any integration for WOL I can't find any Wake on Lan Integration, maybe its the MQTT that created something?
DrR0x
DrR0x4d ago
Wake on Lan doesn't appear as an integration, it doesnt have config, its all done through configuration.yaml
Dutchbear
DutchbearOP4d ago
Weird then that a entity appeared with the WOL integration since I didn't configure anything aside from the thing in configuration.yaml But I can boot up my pc again and I can turn it off through HA so
DrR0x
DrR0x4d ago
is the entity configured in one of ur config files?
Dutchbear
DutchbearOP4d ago
Only thing I can find is the thing you posted here that I had to put in configuration.yaml
DrR0x
DrR0x4d ago
Oh perfect, just checking Everything working then?
Dutchbear
DutchbearOP4d ago
Yeah it boots up and shutdowns my pc and I can use Google Home for it too

Did you find this page helpful?