Wake on Lan?

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
wiredcharlie
Normal user
Posts: 8
Joined: 28 Sep 2020, 13:58

Wake on Lan?

#1 Post by wiredcharlie » 12 Oct 2020, 01:27

I would like to send WOL magic packet from ESP8266 to wake my music server. Is there a way to do this within Rules?

Thank you

Tony

TD-er
Core team member
Posts: 3377
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Wake on Lan?

#2 Post by TD-er » 12 Oct 2020, 03:04

Nope, we don't have a wake on lan packet generator plugin thingy. (yet?)

User avatar
ThomasB
Normal user
Posts: 736
Joined: 17 Jun 2018, 20:41
Location: USA

Re: Wake on Lan?

#3 Post by ThomasB » 13 Oct 2020, 07:17

WOL seems like a useful thing to add to ESPEasy. Do you need help creating a plugin?

- Thomas

TD-er
Core team member
Posts: 3377
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Wake on Lan?

#4 Post by TD-er » 13 Oct 2020, 13:49

Looks like such a plugin may need an external library, like this one: https://github.com/a7md0/WakeOnLan

User avatar
ThomasB
Normal user
Posts: 736
Joined: 17 Jun 2018, 20:41
Location: USA

Re: Wake on Lan?

#5 Post by ThomasB » 13 Oct 2020, 19:59

Looks like such a plugin may need an external library, like this one: https://github.com/a7md0/WakeOnLan
@TD-er, I started coding the plugin last night using a7md0's WOL library.

Here's a view of the Device page:

Wake On LAN Device Page
Wake On LAN Device Page
wakeOnLan.jpg (118.65 KiB) Viewed 650 times

The basic concept: Installations that only need to WOL one MAC can use the default settings. But users with multiple WOL MAC's can override the defaults using command arguments. Like this:

Code: Select all

WakeOnLan,<Optional MAC ADDR String>,<Optional IP ADDR String>,<Optional Port Number>
Regarding the WOL library, which do you prefer: (1) Extract the required WOL functions and integrate into the plugin's source code, or (2) Add the WOL library to the project lib folder. I can do either, just need some guidance.

- Thomas

TD-er
Core team member
Posts: 3377
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Wake on Lan?

#6 Post by TD-er » 13 Oct 2020, 20:05

I prefer the latter, to include the library complete in the lib folder.
This also gives credits to the original author and makes it easier to update the library if bugs are fixed there.

About the suggested command.
Are the (optional) parameters in such order that only the last parameters can be omitted?

User avatar
ThomasB
Normal user
Posts: 736
Joined: 17 Jun 2018, 20:41
Location: USA

Re: Wake on Lan?

#7 Post by ThomasB » 13 Oct 2020, 20:35

Are the (optional) parameters in such order that only the last parameters can be omitted?
That is Correct. BTW, the Plugin's user default IP and Port settings aren't expected to change after they are setup to work on the user's router. So an ESPEasy device that wakeups several different MAC's would only need a command like this for each WOL event:

Code: Select all

WakeOnLan,01:23:45:67:89:AB
Those installations that only have one MAC to wakeup can use the plugin's user default settings. So the command would be as simple as this:

Code: Select all

WakeOnLan
My goal is to keep it simple and let ESPEasy rules handle the WOL activity. If you have any comments/suggestions then let me know.

- Thomas

TD-er
Core team member
Posts: 3377
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Wake on Lan?

#8 Post by TD-er » 13 Oct 2020, 23:03

ThomasB wrote: 13 Oct 2020, 20:35 [...]

My goal is to keep it simple and let ESPEasy rules handle the WOL activity. If you have any comments/suggestions then let me know.
Couldn't agree more :)

User avatar
ThomasB
Normal user
Posts: 736
Joined: 17 Jun 2018, 20:41
Location: USA

Re: Wake on Lan?

#9 Post by ThomasB » 14 Oct 2020, 01:42

The Wake-On-LAN plugin is working on my Wemos 4MB device. That is to say, the Wemos can wake up a sleeping PC via its Ethernet connection. Now looking for beta users to try it out.

- Thomas

TD-er
Core team member
Posts: 3377
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Wake on Lan?

#10 Post by TD-er » 14 Oct 2020, 10:14

If you make a PR, I can add a test build to it.

User avatar
ThomasB
Normal user
Posts: 736
Joined: 17 Jun 2018, 20:41
Location: USA

Re: Wake on Lan?

#11 Post by ThomasB » 14 Oct 2020, 17:33

Before getting official with a PR it would be nice to have at least one interested user try it out. @wiredcharlie, are you still around?

- Thomas

Wiki
Normal user
Posts: 290
Joined: 23 Apr 2018, 17:55
Location: Germany

Re: Wake on Lan?

#12 Post by Wiki » 14 Oct 2020, 18:02

Unfortunately at the moment I am not at home and here I don't have any device which could be configuered for WOL. But I'm very excited testing and using this feature. It will take some five days or so to be back home, I will report and ask if testing is still needed.

Code: Select all

pi@raspberrypi:~ $ man woman
Kein Handbucheintrag für woman vorhanden
pi@raspberrypi:~ $

User avatar
ThomasB
Normal user
Posts: 736
Joined: 17 Jun 2018, 20:41
Location: USA

Re: Wake on Lan?

#13 Post by ThomasB » 14 Oct 2020, 20:32

@Wiki, thanks volunteering. Let me know what ESPEasy device you have (or give me the name of the bin file you're currently using) and I'll provide ready-to-run compiled firmware.

For validation I used a WIN10 PC. I had to enable WOL in the PC bios and configure the WIN10 power settings on its Ethernet device.

Some useful tools for playing around with WOL:
WakeMeOnLan, WOL Scanner/Sender: https://www.nirsoft.net/utils/wake_on_lan.html
wolsniffer, WOL Packet Analyzer: https://apreltech.com/Downloads/wolsniffer.zip

- Thomas

Wiki
Normal user
Posts: 290
Joined: 23 Apr 2018, 17:55
Location: Germany

Re: Wake on Lan?

#14 Post by Wiki » 16 Oct 2020, 11:24

I am using Wemos D1 only, my used bin files are ESP_Easy_mega_XXXXXXXX_normal_ESP8266_4M1M.bin. Lateron the feature will be used manly on my central control device, using the _dev_ release for being able to use the Nextion plugin. But at first this special device will not be available for playing around with considerung the WAF in my house.

Stiil takes some days to return home.

I will test with one Win7, one WinXP and one Linux Mint PC.

Code: Select all

pi@raspberrypi:~ $ man woman
Kein Handbucheintrag für woman vorhanden
pi@raspberrypi:~ $

User avatar
ThomasB
Normal user
Posts: 736
Joined: 17 Jun 2018, 20:41
Location: USA

Re: Wake on Lan?

#15 Post by ThomasB » 16 Oct 2020, 18:17

Attached is the bin. It's a _test_ESP8266_4M1M_VCC build. BTW, Nextion is included in _test_ releases.
The plugin's name is: Communication - Wake On LAN [Testing]

Some tips:

1. When you first add the WOL task device, blank fields will be automatically populated with default values if you leave them empty. The default value(s) will appear after clicking the Submit button.

2. The standard Magic Packet IP address is 255.255.255.255. If the router does not accept this then use the local subnet IP address with 255 at the end. For example, 192.168.1.255. Some WOL devices will accept magic packets sent to their specific IP too. Common UDP Port values are 0, 7, and 9.

3. The Command Keyword can be WAKEONLAN or the Task's Name. Case insensitive.

4. Command usage is like this:
WAKEONLAN,<Optional MAC Address>,<Optional IP Address>,<Optional Port Number>

5. If you send the command keyword without arguments then all the plugin's default settings are used. However, you can supply the values with the command, which will replace the defaults.
Examples (Task Name is WakeKitchenPC):
WakeOnLan
WakeKitchenPC
WakeOnLan,01:23:45:67:89:AB
WakeOnLan,01:23:45:67:89:AB,192.168.1.255
WakeOnLan,01:23:45:67:89:AB,255.255.255.255,9

6. You can have several instances of the plugin. Each must have a unique task name. Use the task name as the command keyword.

7. The nirsoft wake_on_lan utility is handy for sending WOL packets to test a sleeping PC:
https://www.nirsoft.net/utils/wake_on_lan.html

8. Troubleshooting:
- I suggest using the nirsoft util to confirm the PC's WOL works before trying the ESPEasy plugin.
- The WOL plugin provides Serial Log messages for troubleshooting. Set Serial log level to info (Tools->Advanced-> Log Settings). WOL log messages are prefixed "WAKE ON LAN:".
- PC's with integrated WiFi and Ethernet ports will likely have two MAC addresses, with specific WOL settings for each one.
- I don't believe USB connected network adapters are capable of WOL; Check the adapter's manual.


- Thomas
Attachments
ESP_Easy_mega_20201016_test_ESP8266_4M1M_VCC.zip
Wake-On-Lan Beta Test bin
(648.75 KiB) Downloaded 22 times

wiredcharlie
Normal user
Posts: 8
Joined: 28 Sep 2020, 13:58

Re: Wake on Lan?

#16 Post by wiredcharlie » 17 Oct 2020, 13:25

Wow ThomasB - Thank you so much for this!

I just tried it and it woke my music server.

I need IRSend, so I'm using this version:
ESP_Easy_mega_20200913_minimal_IRext_ESP8266_4M1M

I'd be extremely grateful if you could combine the two please?

Thanks
Tony

User avatar
ThomasB
Normal user
Posts: 736
Joined: 17 Jun 2018, 20:41
Location: USA

Re: Wake on Lan?

#17 Post by ThomasB » 17 Oct 2020, 19:31

@wiredcharlie, thanks for confirming the WOL plugin is working. Here's the minimal_IRext_ESP8266_4M1M firmware build you requested:

- Thomas

wiredcharlie
Normal user
Posts: 8
Joined: 28 Sep 2020, 13:58

Re: Wake on Lan?

#18 Post by wiredcharlie » 17 Oct 2020, 23:48

ThomasB, thank you very much indeed!

User avatar
ThomasB
Normal user
Posts: 736
Joined: 17 Jun 2018, 20:41
Location: USA

Re: Wake on Lan?

#19 Post by ThomasB » 18 Oct 2020, 02:16

@wiredcharlie, You're welcome. Thank you for trying it out.

@Wiki, I'm looking forward to your feedback.

@TD-er, After I prepare the readthedocs rst file I'll submit a PR for the new plugin.
I temporarily assigned it P248. For the official PR, what plugin number would you prefer I use?

BTW, the plugin's ESP8266 Flash size is ~5.2KB and RAM usage is under 180 bytes.
Build release _test_ESP32_4M316k successfully compiles. But I haven't installed it on a ESP32.

- Thomas

Wiki
Normal user
Posts: 290
Joined: 23 Apr 2018, 17:55
Location: Germany

Re: Wake on Lan?

#20 Post by Wiki » 18 Oct 2020, 10:32

Yepp, I know. I will start today my way back home (I posted before here where I am I don't have any WOL capabler devices) where I will be able to test and I will report...

Code: Select all

pi@raspberrypi:~ $ man woman
Kein Handbucheintrag für woman vorhanden
pi@raspberrypi:~ $

wiredcharlie
Normal user
Posts: 8
Joined: 28 Sep 2020, 13:58

Re: Wake on Lan?

#21 Post by wiredcharlie » 18 Oct 2020, 10:56

My project is a Google Nest interface - voice control.

I've got a D1 Mini that is controlling my kitchen TV by IR and will also turn on my Squeezebox (LMS) music server and put the radio on by local http request. The music server spends most of its time in standby - hence the need for WOL. Events on the ESP are triggered by Webhooks from IFTTT which are initiated by yelling at the Google assistant.

WOL is completely reliable so far! Google voice command recognition, less so.

It is necessary to insert a delay between WOL and http request in order for the server to actually wake. Since it cannot be known if the server is already awake, it would be useful to have sendToHttp with acknowledge and a configurable timeout. I don't think Easy ESP does this - but I've only been playing with it for a few weeks. (If I repeat the request to start the radio I get a momentary silence on re-start). The optimal (most responsive) solution would involve a loop which re-sends http until an acknowledge is received.

Thanks for your help

Tony

User avatar
ThomasB
Normal user
Posts: 736
Joined: 17 Jun 2018, 20:41
Location: USA

Re: Wake on Lan?

#22 Post by ThomasB » 18 Oct 2020, 19:39

Since it cannot be known if the server is already awake, it would be useful to have sendToHttp with acknowledge and a configurable timeout.
You could use the ping plugin. It is available in the test builds if you want to experiment with it.

- Thomas

TD-er
Core team member
Posts: 3377
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Wake on Lan?

#23 Post by TD-er » 18 Oct 2020, 21:08

Thomas, you can use Plugin ID 101.
Looks like a nice number for network related plugin :)

User avatar
ThomasB
Normal user
Posts: 736
Joined: 17 Jun 2018, 20:41
Location: USA

Re: Wake on Lan?

#24 Post by ThomasB » 19 Oct 2020, 00:32

Thomas, you can use Plugin ID 101.
Thanks, I'll use 101.

Edit: See PR #3328, https://github.com/letscontrolit/ESPEasy/pull/3328

- Thomas
Last edited by ThomasB on 20 Oct 2020, 18:31, edited 1 time in total.

TD-er
Core team member
Posts: 3377
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Wake on Lan?

#25 Post by TD-er » 19 Oct 2020, 00:36

Plugin writing 101 :)

Wiki
Normal user
Posts: 290
Joined: 23 Apr 2018, 17:55
Location: Germany

Re: Wake on Lan?

#26 Post by Wiki » 24 Oct 2020, 12:43

I had to return as fast as possible to the location where I didn't have any WOL capable device but I carried a Laptop with me, Lenovo X201, and additionally an old Fritz Box 7272.

Using the tools you've linked I don't get any WOL Magic packet through one of my routers. Neither using the WOL tool nor from the ESPEasy device. The WOL sniffer on the target device only reports magic packets when sent out of the local device but sent from another PC or from ESPEasy no packet arrives at the destination.

Configuration:

- Fritzbox 7272 attached by cable to Speedport W 925V for internet connection, building up its own Wlan
- Lenovo X201 Win7 attached to Fritz 7272 using Ethernet cable, WOL enabled in BIOS, during poweroff the ethernet led shows that it is active as expected.
- PC Win10 connected to Fritzbox by Wlan
- Wemos D1 with WOL plugin connected to Fritzbox by Wlan
- Connections between the several clients of the Frotzbox works stable, internet connection, too.

Using the Fritz Box 7272 log ESPEasy:

Code: Select all

2247618 : Info  : WAKE ON LAN: MAC Addr= f0:de:f1:48:bf:ed, IP Addr= 192.168.188.255, UDP Port= 9
Sending from a PC (which is connected by Wlan) using nirsoft WakeMeOnLan the local sniffer on this sending PC tells me:

Code: Select all

Time received:
	 10/24/20	 12:26:51
UDP Header:
	|-Source IP	:	192.168.188.25
	|-Destination IP	:	192.168.188.255
	|-Source Port	:	61979
	|-Destination Port	:	40000
	|-UDP Length	:	110
	|-UDP Checksum	:	21745
MAC Address:
	 F0 DE F1 48 BF ED
Raw Data (102 bytes):
	 FF FF FF FF FF FF F0 DE F1 48 BF ED F0 DE F1 48
	 BF ED F0 DE F1 48 BF ED F0 DE F1 48 BF ED F0 DE
	 F1 48 BF ED F0 DE F1 48 BF ED F0 DE F1 48 BF ED
	 F0 DE F1 48 BF ED F0 DE F1 48 BF ED F0 DE F1 48
	 BF ED F0 DE F1 48 BF ED F0 DE F1 48 BF ED F0 DE
	 F1 48 BF ED F0 DE F1 48 BF ED F0 DE F1 48 BF ED
	 F0 DE F1 48 BF ED
Starting the WOL sniffer on the Lenovo, no packets arrive.
Sending WOL from ESPEasy to the Wlan connected PC, WOL sniffer started, using the Wlan Mac, no packets arrive.

Any suggestions?

Code: Select all

pi@raspberrypi:~ $ man woman
Kein Handbucheintrag für woman vorhanden
pi@raspberrypi:~ $

TD-er
Core team member
Posts: 3377
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Wake on Lan?

#27 Post by TD-er » 24 Oct 2020, 14:03

WOL packets are usually only useful for local networks, so I can imagine default filter rules in network devices may block WOL packets.

I have not looked thoroughly at the used library, nor the implementation Thomas made.
The WOL packet needs to have an IP address and MAC address of the host to power on.
So when sending the WOL setup, the MAC address must be resolvable.
Typically this is done using an ARP packet, but since the host is not online there is no-one to help with such an ARP request.
If you're on the same network (only layer 2) you don't need any routing and it should work.
As soon as you need to route the packet to another subnet, the gateway to the final subnet must know the combination IP/MAC. (IP & MAC binding in DHCP config for example)

A WiFi access point is typically more then a simple layer 2 gateway, so it might be these WOL packets are blocked, or somewhere in the network it is unknown how to route packets to the destination subnet (e.g. different subnetmask, or subnet)

Are the ESP and the host to wake in the same IP subnet?
Is the ESP allowed to send data to the host connected to the LAN port (e.g. guest network isolation)

Wiki
Normal user
Posts: 290
Joined: 23 Apr 2018, 17:55
Location: Germany

Re: Wake on Lan?

#28 Post by Wiki » 24 Oct 2020, 16:39

Yes, all your explanations I know, the devices are all directly connected to the box, the PC and ESPEasy by Wlan, the Laptop by ethernet cable, no firewalls, no routing, no guest net. I just did't get so far to test ESPEasy, I just don't get any magic packet through the router - pretty strange.

The Fritzbox has been used for ten years or so, I just made a reset. Now I downloaded the tool from AVM to recover the box and will erase it completely. AVM once created this tools to reanimate hacked boxes (eehm, what I did do in the past to get telnet access), so it will be clean afterwards. Starting afterwards from scratch and will report.

Code: Select all

pi@raspberrypi:~ $ man woman
Kein Handbucheintrag für woman vorhanden
pi@raspberrypi:~ $

User avatar
ThomasB
Normal user
Posts: 736
Joined: 17 Jun 2018, 20:41
Location: USA

Re: Wake on Lan?

#29 Post by ThomasB » 24 Oct 2020, 17:55

PC Win10 connected to Fritzbox by Wlan
That might be the problem. The Fritzbox instruction manual states that the WOL device must be connected to a LAN port.

General Info:

If the chosen WOL IP address is already in-use some routers will not broadcast the WOL magic packet.

You may need to use a different UDP port. All devices need to be on the same local subnet.

The Packet Sniffer tool is not 100% reliable. For example, it only reports packets sent to IP's that end with 255.

WiFi WOL is not supported on all computers. The motherboard should have integrated WiFi (not USB WiFi) and BIOS settings for the WiFi WOL. Typically these computers have separate MAC for wired LAN and WiFi.

If you are sure the computer is correctly configured for WOL, then try sending the WOL directly to its assigned IP. Keep in mind the packet sniffer might not report this magic packet, so you will need to rely on the computer to wake up.

You Fritzbox apparently has built in WOL. Try it to see if the packet sniffer detects WOL packets when you use this feature.
https://en.avm.de/service/fritzbox/frit ... ke-on-LAN/

Some routers don't work well with WOL packet senders. Check with the fritzbox forums to see if there are discussions about this.

Check the general troubleshooting tips posted here: https://wiki.dd-wrt.com/wiki/index.php/WOL
I know, not the same router you use. But the tips might help.

Consult the WOL Plugin's readthedocs too:
https://espeasy.readthedocs.io/en/lates ... /P101.html

Conitnue to do your troubleshooting using this tool:
WakeMeOnLan, WOL Scanner/Sender: https://www.nirsoft.net/utils/wake_on_lan.html
If this tool has problems sending magic packets through your router then I doubt that the WOL plugin will work.

- Thomas

Wiki
Normal user
Posts: 290
Joined: 23 Apr 2018, 17:55
Location: Germany

Re: Wake on Lan?

#30 Post by Wiki » 25 Oct 2020, 07:55

Resetting the Fritzbox by using AVM's tool isn't possible, it stops with the message that there is a provider specific configuration on it. What a mess...

Well, I try to wakeup the Laptop, which is connected to a lan port of the Fritz, running Win7. The PC on Wlan is only to be able to doublecheck ESPEasy's success or fail.

But I will follow your suggestions and report.

Code: Select all

pi@raspberrypi:~ $ man woman
Kein Handbucheintrag für woman vorhanden
pi@raspberrypi:~ $

Post Reply

Who is online

Users browsing this forum: No registered users and 16 guests