A lightweight Node.js service that calls a webhook on Wemo device state transitions, e.g. from 'On' to 'Standby'. Primarily useful for announcing the completion of activities for devices that do not otherwise have an audible alert, e.g. coffeemakers and electric kettles.
N.B. - This project has only been tested with Wemo Smart Plugs, but should work in principle with other devices.
This is a Node.js server, and this documentation will assume that Node.js is installed, and that the user has some familiarity with Node.js and npm.
This project should run on most modern Debian variants. It may run on other operating systems; YMMV.
- 
Clone this project git clone https://github.com/mpaik/wemo-control.git cd wemo-control
- 
Install the server and dependencies N.B.: This project is not available via the public npmrepository due to its alpha quality and likely limited userbase.npm install
The config.json file contains all the configuration information for the application. These include:
logFile - String. Name of logfile. This project uses Winston logging.
fileLogLevel - String. Log level for file logger.
consoleLogLevel - String. Log level for console logger.
triggers - Contains configuration for webhooks to be called on state transitions of Wemo devices. Each child of this object is a named device, e.g. Coffeemaker that contains its own configuration information, consisting of:
- 
fromState: The start state of the edge transition upon which to fire an action. Valid values areon,off, andstandby
- 
toState: The end state of the edge transition upon which to fire an action. Valid values areon,off, andstandby. Note that the event will be fired if and only if the device transitions directly fromfromStatetotoState- transitions with intervening steps will not cause the event to fire. For instance, a transition edge fromontooffwill not be fired if the device goes fromontostandbyand then fromstandbytooff. Also note that not all Wemo devices support all of these states.
- 
webhookUrl: The url of the webhook to be called on the configured state transition
- 
webhookMethod: The method via which to call the webhook, e.g.GETorPOST. Note that ifGETis used, the content of the JSON posted will be exposed; therefore theGETmethod is not advised and is only provided for completeness for webhook services that do not acceptPOSTrequests.
- 
webhookContentType: The content type of the request. Typicallyapplication/json
- 
webhookRequestBody: The body content of the request. Note that this has only been tested with JSON viaPOST; other data formats or use viaGETmay or may not work as intended. Pull requests with enhancements welcomed.
The request body should contain all the information necessary to trigger the webhook, including credentials. Other authentication mechanisms are not presently supported. Pull requests with enhancements welcomed.
Once the server is configured, it can be run with npm run start, or simply node wemo-control.js.
The server will activate and periodically poll for Wemo devices visible on the local network.
To test that the server is operating as intended, toggle power to Wemo devices after the detection routine has polled for devices. The log should display the state changes made.