Switch creation / Wake on LAN

Hi @ondras12345,

also checked! No Entry…

i dont get it what the problem is… same code on other instance works.

Ok, this is probably not going to help, but try refreshing the frontend with ctrl+F5. That should ignore your browser’s cache and reload everything. It sometimes happens to me that when I add a new entity, I cannot access it from the entity filter quick bar. Maybe this is something similar.

also dont works :frowning: i think i try a reinstallation…

Try changing the name of the switch. Maybe there’s some weird name conflict.

good idea! tried it, but dont worked :frowning:

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:

  1. 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
  1. 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

2 Likes

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 :thinking:
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
4 Likes

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.

  1. 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.

  1. 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).

  2. Turn off your Raspberry Pi or whichever devices you use.

  3. 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.

  4. 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. :slight_smile:

1 Like