Switch creation / Wake on LAN

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

The broadcast (and listening) address depends on the netmask in use.
You can find it using this site
https://jodies.de/ipcalc

1 Like

image

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