npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

wol-server

v2.3.0

Published

Configurable Wake On Lan Server for home automation

Downloads

15

Readme

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

| URL | Query Params | Description | Sample | | --- | ------------ | ----------- | ------ | | wake/:macAddress | Any valid option for node_wake_on_lan (all optional) | Sends a WOL Magic packet to the computer at :macAddress | localhost:3078/wake/AA:BB:CC:DD:EE:FF | | /wake | Same as above | Does the same as above but uses WOL_SERVER_MAC_ADDRESS_TO_WAKE environment variable as the macAddress | localhost:3078/wake | | /:ipAddress/:action | None | Used to perform sleep or power-off on stop-server instance | localhost:3078/192.168.1.12/sleep | | /remote/:action | url 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 post | This is call can be used to make a call to any URL | localhost:3078/remote/sleep?ip=192.168.1.10&port=5709 | | /healthcheck | None | Used to test whether the server is currently running or not | localhost:3078/healthcheck |