1.1.2 • Published 7 years ago

energenie-magic v1.1.2

Weekly downloads
3
License
MIT
Repository
github
Last release
7 years ago

energenie-magic

Package to get and set states of the energenie power strip sockets.

Tested with Node 8.5.0 and EG-PMS2-LAN.

Installation

npm install --save energenie-magic 

Samples

See in /samples folder for some examples. You can try after adding to node_modules with your power strip via cli:

# Get sockets of power strip
node .\node_modules\enegenie-magic\samples\getSockets --host <ip-adress/hostname> [--port <default: 80> --password <default: ''>]
# Set socket state of power strip 
node .\node_modules\enegenie-magic\samples\setSocket --host <ip-adress/hostname> --id <id> [--port <default: 80> --password <default: ''> --state <default: true>]

Usage

const EnergenieManager = require('energenie-magic');
  /* Add your power strips */
  let powerStrips = new EnergenieManager([
    {
      host: '192.168.78.79',
      port: 80,
      password: ''
    }
  ]);

getSockets()

Get information of sockets of the connected power strip.

power_strips.getSockets().then(function(sockets) {
    console.log(sockets);
}).catch(function(err) {
    console.error(new Error(err)); 
});

sockets looks like:

[{
  host: "192.168.78.79",
  name: "Wohnzimmer",
  sockets: [{
    key: "cte1",
    state: true,
    name: "Socket A"
  }, {
    key: "cte2",
    state: true,
    name: "Socket B"
  }, {
    key: "cte3",
    state: true,
    name: "Socket C"
  }, {
    key: "cte4",
    state: true,
    name: "Socket D"
  }]
}, ...]

setSocketState(powerStripOptions, id, state)

Set socket of power strip.

  • host: Hostname or IP-Adress of power strip.
  • id: Key/ID of socket.
  • state: Bool represents on/off.
/* Turning first plug off. */
power_strips.setSocketState('192.168.78.79', 'cte1', false)
  .then(function(val) {
    console.log(val);
  }).catch(function(err) {
    console.error(new Error(err));
  });
1.1.2

7 years ago

1.1.1

7 years ago

1.1.0

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago