2.3.0 • Published 5 years ago

wol-server v2.3.0

Weekly downloads
3
License
ISC
Repository
github
Last release
5 years ago

WOL-Server

This tool starts up a server to wake up your machine by calling one of the routes.

Why?

I wanted to be able to turn on and off my computer using amazon alexa. So I setup a Raspberry PI that stays on all of the time running ha-bridge which then calls this server (which is also running on the raspberry pi). This allows me to turn on my computer using node_wake_on_lan and turn off my computer using stop-server (which is running on the computer I want to turn off and on).

How does it work?

After installing:

$ wol-server start
WOL Server now running on default port 3078
# The server is running on it's default port ready to accept requests

And I guess I do stop to stop it right? Yes.

$ wol-server stop
WOL Server stopped running
# The server is no longer running

I don't like that port though:

$ wol-server start --port 9000
WOL Server now running on port 9000
# The server is running on port 9000 ready to accept requests

I want this to run on startup!

sudo wol-server startup
WOL Server now runs on startup running
# The server will now restart on startup of the computer
# Sudo is required because the libary I'm using (pm2) requires it

Ok, I don't want it to run on startup anymore

sudo wol-server unstartup
WOL Server no longer runs on startup
# The server will now not restart on startup of the computer

Install

npm install wol-server -g

Usage

Once you have the server running you'll have the ability to use a few routes to trigger turning on and off the computer. Here are some useful ones:

Turning on a computer with WOL Magic Packet

http://localhost:3078/wake/AA:BB:CC:DD:EE:FF

Where AA:BB:CC:DD:EE:FF is the Hardware MAC address of the computer you want to turn on (note WOL only works over ethernet).

Turning off a computer that is running stop-server

http://localhost:3078/192.168.1.12/sleep

To sleep the computer at 192.168.1.12 (which I found is the only way my machine will wake up to a WOL Magic Packet but your expierence may vary).

http://localhost:3078/192.168.1.12/power-off

To turn off the computer at the IP address 192.168.1.12 which you should definitely change.

What to do with these URLs

Put them into ha-bridge by:

  1. Creating a new device by going to "Home" > "Add/Edit" > "Add Bridge Device"
  2. Set "Type" to "HTTP Device" for "On Itmes", Put the wake URL in the "Target Item" section and make sure to click "Add" on the far right.
  3. Set "Type" to "HTTP Device" for "Off Itmes", Put the sleep or power-off URL in the "Target Item" section and make sure to click "Add" on the far right.

All Routes

URLQuery ParamsDescriptionSample
wake/:macAddressAny valid option for node_wake_on_lan (all optional)Sends a WOL Magic packet to the computer at :macAddresslocalhost:3078/wake/AA:BB:CC:DD:EE:FF
/wakeSame as aboveDoes the same as above but uses WOL_SERVER_MAC_ADDRESS_TO_WAKE environment variable as the macAddresslocalhost:3078/wake
/:ipAddress/:actionNoneUsed to perform sleep or power-off on stop-server instancelocalhost:3078/192.168.1.12/sleep
/remote/:actionurl defaults to WOL_SERVER_POWER_OFF_URL environment variable if set will override all other options and send a request to that URL, ip the IP address to make the call to, port the port to make the call to on the IP defaults to 5709, method the http verb method to make the call with defaults to postThis is call can be used to make a call to any URLlocalhost:3078/remote/sleep?ip=192.168.1.10&port=5709
/healthcheckNoneUsed to test whether the server is currently running or notlocalhost:3078/healthcheck
2.3.0

5 years ago

2.2.0

5 years ago

2.1.0

5 years ago

2.0.0

5 years ago

1.4.0

5 years ago

1.3.1

5 years ago

1.3.0

5 years ago

1.2.2

5 years ago

1.2.1

5 years ago

1.2.0

5 years ago

1.1.0

5 years ago

1.0.0

5 years ago