Try changing the name
of the switch. Maybe thereâs some weird name conflict.
good idea! tried it, but dont worked
You have quotations for both name and mac address and the host is commented out - this is wrong.
Here is what I have in mine and it works:
- switch.yaml
- platform: wake_on_lan
mac: 00:11:22:33:44:55
name: server
host: 192.168.1.X
turn_off:
service: shell_command.turn_off_server
- configuration.yaml
## wol ##
wake_on_lan:
shell_command:
turn_off_server: "ssh -p 59622 [email protected] 'sudo systemctl start systemd-suspend'"
and add this to point your configuration.yaml to the switch.yaml file
# Configure a default setup of Home Assistant (frontend, api, etc)
default_config:
# Text to speech
tts:
- platform: google_translate
group: !include groups.yaml
automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml
## New entries
switch: !include switch.yaml
That pretty much it and ensure you follow the WOL guide for the rest as previously posted above by @krskrab:
Good luck and hope this helps
Note: I am using fedora for my server with NVIDIA card so my command to suspend differs from the WOL guide in HA
I have a problem getting the shell script to work to turn off the server. The current code is:
switch:
- platform: wake_on_lan
mac: "00:11:32:26:xx:xx"
turn_off:
service: shell_command.turn_off_kanga
shell_command:
turn_off_kanga: "/usr/bin/ssh -i /config/scripts/id_rsa -o UserKnownHostsFile=/config/scripts/known_hosts [email protected] 'sudo shutdown now'"
I have automatic login into the synology server based on key pairs and âsudo shutdown nowâ can be used by the user on the server without password. known_hosts and id_rsa has been copied to the /config/scripts directory.
When I turn the switch off I get an error 255 so it seems the login into the server seems not to work. Anyone understands what goes wrong?
this is my current setup and that works:
switch:
- platform: wake_on_lan
mac: "00:11:32:26:XX:XX"
turn_off:
service: shell_command.turn_off_kanga
shell_command:
turn_off_kanga: "/usr/bin/ssh -i /config/scripts/id_rsa -o UserKnownHostsFile=/config/scripts/known_hosts [email protected] 'sudo shutdown now'"
Some networks require the broadcast address
Maybe this helps?
Sorry Iâm confused.
First your saying it didnât work and now your saying it works?
Which is it?
HI!
I have the exact same issue u had.
My code in another installaition works, 2 months ago in mine installation works too but now no more.
No switch is getting created.
You have solved only reinstallint HA?
Any sudgestions?
If you followed the official guide and it doesnât work, then is there any chance you are putting the wrong mac address? Some people mix up their wifi mac vs lan, etc.
For me I only have the following in the configuration.yaml and the switch comes up under Entities as âswitch.wake_on_lanâ and it works fine.
switch:
- platform: wake_on_lan
mac: XX:XX:XX:XX:XX:XX
Thanks for the reply Dundy!
Even if u put a wrong mac, on a new installation, the switch is created but in my current installation it didnât even create the switch at all.
The problem is soo strange even after all the update of those days nothing changed same issueâŚ
This is really frustrating!!!
I googled for âHome Assistant Wake on Lanâ and this is one of the places I was referred to.
I did get mine to work. I followed a youtube video from 2021.
My system is slightly different than his. I have x86-64. On linux, windows, or rpi it might be slightly different. But it did work.
As far as the button not being automatically created: If you are using a new installation, widgets are automatically placed on the overview page. If you made changes to the overview page, it no longer automatically creates stuff. As shown in the video, just edit the overview page, and add a button. I hope that helps.
I didnât like the way the switch looked, because it was acting as a switch with an âonâ and an âoff.â
Also, I only want to turn on the computer, and not turn it off.
I really wanted a momentary push button.
So, I went into the overview page, and edited the page. (using the gui) On the WOL card, I changed the entity to blank, and changed the tap action from toggle to call service. And the service to call was âWake on Lan: Send Magic Packetâ It required that I put in the mac address. Works fine. I also deleted the switch section that says wake on lan. I still have the âwake_on_lan:â in my config.yaml
Code for the button widget on the overview screen
show_name: true
show_icon: true
type: button
tap_action:
action: call-service
service: wake_on_lan.send_magic_packet
target: {}
data:
broadcast_port: 9
mac: b0:83:fe:85:c1:8f
name: tvpc
For all the people that had the issue of the switch not showing, the thing that solved my issue, was restart home assistant. But do full restart, not âQuick reloadâ. After quick reload nothing was shown as entitie, but after full restart, i can see it.
The issue I am having is that one of my PC switches shows up like all the others, but it showing unavailable and grayed out, despite being defined identically to all of the others, implying that WoL is unable to ping it for status, but I can ping it manually from a Terminal screen just fine. Not sure if something needs to be configured on the PC end, but if a ping is working, and the WoL documentation implies that ping is what it uses to determine the switch state, I donât see what would be.
Thanks, that works great!
This one actually took me a while to find out! I would like to contribute to whoever still finding out the solution.
- Add the below code to your configuration.yaml, I used File editor in Addons to edit my configuration.yaml. You will need to define the host, mac address and broadcast_address accordingly. Leave everything else the same.
switch:
- platform: wake_on_lan
name: LG_TV_WOL
host: 192.168.0.123
mac: "44:00:00:00:00:00"
broadcast_address: 192.168.0.255
the 192.168.0.255 is usually at the end of the gateway of your current host IP address in my case it was 192.168.0.255 as a local gateway.
-
Make sure your TV has Wake on LAN turned on. I tested working by downloading a free WOL app from my App Store, or Play Store (whichever you use).
-
Turn off your Raspberry Pi or whichever devices you use.
-
Now go to Overview > Edit dashboard > select Button > and choose the Entity of LG_TV_WOL, tick Show Name, State and Icon. choose Toggle in Tap action and SAVE.
-
Make sure your TV is off (of course, since this is a turning-on feature only) and now try to press on. I tried many steps but without any luck earlier. Hope it helps someone.
The broadcast (and listening) address depends on the netmask in use.
You can find it using this site
https://jodies.de/ipcalc
if i use a button it will error out. if i use the ssh shell on Homeassistant and send the same command it works.
any ideas?
Any idea how you can make the switch a momentry one. The wake on LAN switch I have needs to be turned off after I activate it