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:Jump to solution
```yaml
- platform: wake_on_lan
mac: mac_address
host: ip
name: "My PC Power"...
106 Replies
Have you connected the home assistant shutdown button to google home?
WoL is one directional, only starts
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.
NGL idk how that would work, was it a WoL entity in HA?
that triggered shutdown?
Yes. Switch.(computername)_wol was the entity name.
That one currently wakes the computer up.
WoL as in the HA integration? how does that single entity connect with a separate hass.agent entity?
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.
What integration was the entity attached to?
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.
Merging 2 integrations isn't really possible, however you can create helper switches/groups that could do this
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.
I think the best way would be 2 automations with a helper toggle
Hmm okay. I need to see then how I can configure this since I am new to Home Assistant.
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
So create 1 toggle helper for switching on/off and then 2 automations?
Did this work?
It did not, but I didn't really think about it anymore after it didn't work
Do you still want to get this working?
if it can yes
Can you send me your WoL config?
sanitise if needed
and use codeblocks, put 3 at top and bottom
I can do that tonight (local time)
timezone?
CET/CEST
<t:1737136800:R>?
Sure.
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
Alright
Only thing I could find really is this:
Don't really know where else to look. Maybe I have to reconfigure it completely, but I am not that experienced with HA
These both hass.agent?
No idea tbh a friend of mine sent me it and told me to put in a .yaml file
Ah okay, how many hass.agent PCs do you have?
1 the second platform is the RP that is hosting HA
Okay, so how did you edit .yaml? Do you have the file editor add on?
Yes studio code server
Okay, can you show me up a few lines of the snippet U sent? Specifically whether it's a button or a switch
The text I shared is a .yaml file called scripts and then the configuration.yaml file has this:
Can you show me a scrshot of the script you use to turn it on through HA
Let me see if I can find it
Found it I think
can you show me a scrshot of the
switch.pc-name-wol
?
in the dashboard i meanWhat do you mean exactly?
ah okay
Click 3 dots and 'device info'
It only says "related"
is there any mention of
switch
in configuration.yaml?switch: !include switch.yaml is there and in switch.yaml is the file where this is:
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
Sorry for the delay, this is my config
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
.And I need to put that in switch.yaml right?
yeah, specifically the
turn_off
and below should be copied to ur pcAlright
Where this is placed. It says the error:
service: switch.turn_on and service: button.press is having that error
oh do you use the locking funcitonality?
because you can delete that script
I can delete this completely?
yep
Alright
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 volumeDeveloper 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
you have
turn_off
right?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?
by script you mean switch.yaml?
Yes
I copied your text and replaced my thing in switch.yaml
HA version?
Core: 2025.1.2
Supervisor: 2024.12.3
Operating System: 14.1
Okay try putting this in configuration.yaml, just for testing
And remove the one from switch.yaml
I now get multiple things:
Missing property "switches"
Bad identation of a mapping entry
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 againThe errors are gone now
Should I keep it in configuration.yaml?
just test it first, turn pc off and then back on
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
what if you manually trigger the button.my_pc_shutdown, from the HA interface?
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"
send me a scrshot of your hass.agent commands config
is the shutdown command a button or switch?
Button
The WOL is a switch
okay try clicking the button in HA
just need to ensure the shutdown is working
Just says this
Can't press like a switch to turn it on or off
okay remove it from HASS.Agent, then check if it stills hows under mqtt
then re-add it
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
just try the switch then
the WoL switch
Do I need to change the script thing to the new shutdown name?
yes, if you changed it
Alright
Hmm when I use the WOL switch it still doesn't say a warning message
and doesn't shutdown the pc?
try the button then
if that doesn't work then somethings wrong with hass.agent
Button works got the message
My pc is shutting down in a bit
try restarting home assistant
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
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
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?
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
Weird. The boot up part doesn't work, but the turn off part does work
Means integration is working, but magic packet isn't, anymore
logs have anything?
Nop
Problem is solved. Out of nowhere a new entity was made automatically of my pc and now both WOL and shutdown works
just to help people in future could you send a screenshot of the entity
Sure:
Is this the one created from our config?
WoL doesn't do autodiscovery afaik, so you must have configured it
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?
Wake on Lan doesn't appear as an integration, it doesnt have config, its all done through
configuration.yaml
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
is the entity configured in one of ur config files?
Only thing I can find is the thing you posted here that I had to put in configuration.yaml
Oh perfect, just checking
Everything working then?
Yeah it boots up and shutdowns my pc and I can use Google Home for it too