Help with WOL and ping

Hello!!
I need some help for the WOL integration in HA.
I have added this string in the configuration.yaml:

switch:
  - platform: wake_on_lan
    name: PC-Studio
    mac: D0:50:99:XX:XX:XX
    host: 192.168.0.36

and when i turn the switch on the PC will turn on but the switch turn back to OFF…

if i add this:

binary_sensor:
- platform: ping
  name: PCStudio
  host: 192.168.0.36
  count: 2
  scan_interval: 30

the binary sensor work well.
I think there is a problem with the Ping in the WOL… some suggestion?

Stefano

If you wait some time, does the switch turn to ON?
For my WOL switches this is normal as it takes some time until the PC responds.

Yes, i have the pc running for about 30 minutes but the switch still off…
The binary sensor stay on

Thanks a lot for your reply
Stefano

That’s odd. I use the WOL switches without the wol service instead of the ping sensors because i find them more reliable.
Here’s an example of my NAS. Maybe the format of the mac adress?

  - platform: wake_on_lan
    mac: "00-14-FD-XX-XX-XX"
    name: 'Terra NAS'
    host: 192.168.123.151

Give it a try.

Forget about the mac format.
Looking at the code, the commands used in the WOL switch are:

# Windows
ping -n 1 -w 1000 192.168.0.36

# Linux
ping -c 1 -W 1 192.168.0.36

Your ping binary_sensor uses count 2.
I think that’s the culprit.

For now the binary sensor works perfect is the WOL that won’t work…
Do you think that i need to put this inside my config?

  - platform: wake_on_lan
    name: PC-Studio
    mac: D0:50:99:XX:XX:XX
    host: 192.168.0.36

Without the switch before the - platform?

You need to have the switch before the other part.

So this is my configuration:

switch:
  - platform: wake_on_lan
    name: PC-Studio
    mac: D0:50:99:53:24:8C
    host: 192.168.0.36

If i turn the switch to on the pc will turn on but the switch after 2 sec turn off…

1 Like

Is it a windows PC? If so is it on a “private network” in the windows network setting? You may also need to have network sharing on. I forget which it was the last time I had this issue.

The PC is in a LAN and if i use the ping i can ping the device

Thanks for your reply.

I think your problem is on the windows side. Go to the network settings and make sure the network is not public. It should be private. The problem is on the network discovery itself.

Thanks a lot for your reply :smiley:
i have another problem with Alexa Integration so for now i’m trying to solve this issue…
But really thanks for your help :smiley:

Hi,

First of all sorry for my noob question but i’m stuk for day’s now.
I want to setup my samsung tv to wake up of i press a button on my dashboard.
so wat I did:

In my switch.yaml file I put this:

  • platform: wake_on_lan
    name: “Sasman TV”
    mac_address: "d4:9d:Xx:xx:xx
    host: 192.168.86.35

than I made a button.
type: button
tap_action:
action: call-service
service: wake_on_lan.send_magic_packet

If I press this button I get this:
Failed to call service wake_on_lan/send_magic_packet. required key not provided @ data[‘mac’]

I thank you in advance!

You’re doing two different things here.

  1. You created a WOL switch
  2. Calling the wake_on_lan service

With 1. just simply turn your switch on, or call the service ‘switch.turn_on’ in your button.

With 2. you need to provide the mac of the device, like the error says.

And please read here (#11) how to format your code when posting it.

EDIT: Btw, the WOL Switch needs the mac: "d4:9d:Xx:xx:xx", not mac_adress. It’s all in the docs.