https://github.com/thatguydan/wemo.js
Node.js library for interacting with a Belkin WeMo
https://github.com/thatguydan/wemo.js
Last synced: about 2 months ago
JSON representation
Node.js library for interacting with a Belkin WeMo
- Host: GitHub
- URL: https://github.com/thatguydan/wemo.js
- Owner: thatguydan
- Created: 2013-02-04T22:08:54.000Z (about 13 years ago)
- Default Branch: master
- Last Pushed: 2016-02-14T23:49:46.000Z (about 10 years ago)
- Last Synced: 2025-11-20T18:03:53.390Z (5 months ago)
- Language: JavaScript
- Size: 167 KB
- Stars: 21
- Watchers: 1
- Forks: 11
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-iot - wemo.js ★ 19 ⧗ 288 - This library aims to provide a simple interface to a Belkin WeMo Power Sockets. (Protocol Library / WeMo)
- awesome_iot - wemo.js ★ 19 ⧗ 288 - This library aims to provide a simple interface to a Belkin WeMo Power Sockets. (Protocol Library / WeMo)
README
Node WeMo Module
---
This library aims to provide a simple interface to a Belkin WeMo Power Sockets (http://www.belkin.com/wemo).
## To install
```
npm install wemo.js
```
## To use
```javascript
var WeMo = require('wemo.js');
```
## Discover WeMo sockets
```javascript
WeMo.discover(function(wemos) {
console.log(wemos);
});
```
## Simple example to toggle a WeMo
```javascript
var client = WeMo.createClient('x.x.x.x'); // x.x.x.x being the IP of the WeMo obtained in the previous step
client.state(function(err,state) {
if (state===1) {
// WeMo if on, turn it off
client.off();
} else {
// WeMo is off, turn it on
client.on();
}
});
```
## WeMo API
### WeMo.createClient(hostname)
`hostname` being the IP of the WeMo.
### WeMo.Discover(cb)
Discovers WeMo power sockets on your local network.
## Client API
### client.on(cb)
Attempts to turn the WeMo on. `cb` will be passed an error if this failed, or if the device is already on.
### client.off(cb)
Attempts to turn the WeMo off. `cb` will be passed an error if this failed, or if the device is already off.
### client.state(cb)
Fetch the state of the WeMo, 1 is on, 0 is off.