Socket
Socket
Sign inDemoInstall

edimax-smartplug

Package Overview
Dependencies
6
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    edimax-smartplug

Node module to communicate with Edimax Smart Plugs


Version published
Weekly downloads
8
decreased by-66.67%
Maintainers
1
Install size
0.967 MB
Created
Weekly downloads
 

Readme

Source

edimax-smartplug

Greenkeeper badge Build Status

Node module to communicate with Edimax Smart Plugs. The library utilizes Bluebird promises - https://github.com/petkaantonov/bluebird. Device requests will be executed sequentially. This is useful as the Smart Plug REST service does not properly chain incoming requests. It provides the following features:

  • Device Discovery - Smart Plugs can be automatically discovered on a given network (see section "Device Discovery" below for details)
  • Switching - Apart from switching Smart Plugs on and off, it is possible to read the current switch state
  • Schedule - It is not possible to set the schedule for the Smart Plugs, but the current schedule is readable
  • Usage Metering - For 'SP2101W' Smart Plugs it is possible to access the current, accumulated, and historical energy usage metering data
  • Support for digest authentication required with firmware versions SP-2101W v2.08 and SP-1101W v2.04
Important Notice
The recent firmware versions published for EdiSmart/Amazon Alexa Integration
are currently not supported by edimax-smartplug:
  • SP2101W: v2.09 and higher
  • SP1101W: v1.05 and higher

Moreover, please note, the SP-2101W V2 plug is currently not supported. Issue #14 contains a link thread with untested and unsupported downgrade instructions. Use at your own risk!

If you have installed the new version and wish to downgrade you can use the downgrade guide provided as part of the project.

Usage Examples

var smartplug = require('./index');
var options = {
    timeout: 10000,
    name:'edimax',
    host:'192.168.178.65',
    username: 'admin',
    password: '1234'
};


smartplug.getDeviceInfo(options).then(function (info) {
    console.log(info);
}).catch(function(e) {console.log("Request failed: ", e)});

smartplug.getSchedule(options).then(function (schedule) {
    console.log(schedule);
}).catch(function(e) {console.log("Request failed: ", e)});

// set switch ON
smartplug.setSwitchState(true, options).catch(function(e) {console.log("Request failed: ", e)});

smartplug.getSwitchPower(options).then(function (power) {
    console.log("Current switch power", power, "Watts");
}).catch(function(e) {console.log("Request failed: ", e)});

smartplug.getSwitchEnergy(options).then(function (energy) {
    console.log("getSwitchEnergy result:", energy);
}).catch(function(e) {console.log("Request failed: ", e)});

smartplug.getStatusValues(true, options).then(function (all) {
    console.log("getStatusValues result:", all);
}).catch(function(e) {console.log("Request failed: ", e)});

// set switch OFF
smartplug.setSwitchState(false, options).catch(function(e) {console.log("Request failed: ", e)});

// get switch status
smartplug.getSwitchState(options).then(function (state) {
    console.log("Switch status is", state?"ON":"OFF");
}).catch(function(e) {console.log("Request failed: ", e)});

// get schedule status
smartplug.getScheduleState(options).then(function (state) {
    console.log("Schedule status is", state?"ON":"OFF");
}).catch(function(e) {console.log("Request failed: ", e)});

// get the daily history of power measured consumption for the given date range
smartplug.getHistory('DAY', '20160825', '20160830', options).then(function (results) {
    console.log("getHistory result", results);
}).catch(function(e) {console.log("Request failed: ", e)});

// discover devices
smartplug.discoverDevices({
    timeout: 3000,
    address: "192.168.178.255"
}).then(function (results) {
    console.log("Discovery Result:", results);
}).catch(function(e) {console.log("Request failed: ", e)});

Device Discovery

The device discovery implementation is based on the findings summarized in a blog post (thanks, Guntram). As the discovery mechanism may also be used for other Edimax products, e.g. IP cameras, you should filter by model name to make sure the found device is a smart plug ('SP1101W' and 'SP2101W'). The method discoverDevices() accepts the following options:

PropertyDefaultTypeDescription
address"255.255.255.255"StringThe broadcast address
timeout3000IntegerThe timeout in milliseconds for discovery

Note: Using the global broadcast address on Windows may yield unexpected results. On Windows, global broadcast packets will only be routed via the first network adapter which may cause problems with multi-homed setups and virtual network adapters. If you want to use a broadcast address though, use a network-specific address, e.g. for 192.168.0.1/24 use 192.168.0.255.

A discovery request returns a promise which yields an array with the discovery items on completion. An item is an object with the following properties:

PropertyTypeExampleDescription
manufacturerString'EDIMAX'The manufacturer of the device
modelString'SP2101W'The model name
versionString'2.03'The firmware version
displayNameString'edimax'The assigned device name
addrString'192.168.178.65'The IP address of the device
dstAddrString'192.168.178.1'The IP address of the gateway

TODO

  • More Documentation
  • Make request chaining optional. In some cases, request/response interleaving does not matter
  • Add tests

History

See Release History.

License

Copyright (c) 2015-2019, Marcus Wittig and contributors. All rights reserved.

MIT License

Keywords

FAQs

Last updated on 28 Mar 2019

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc