This repository has been archived by the owner. It is now read-only.
node-max is a node.js module to communicate with a eQ3 MAX! Cube.
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
examples
lib
test
.gitignore
.jshintignore
.jshintrc
LICENSE
README.md
gruntfile.js
index.js
package.json

README.md

node-max

License Version

node-max is a node.js module to communicate with a eQ3 MAX! Cube.

Installation

npm install @maexle/node-max

Quick Start

var max = require('@maexle/node-max'),
    discover = max.discover();

discover.once('cube', function(c) {
    var cube = c.connect();
    discover.end();

    cube.on('change', function() {
        console.log('\nCube:');
        console.log(cube.toJSON());
    });

    cube.on('room', function(room) {
        console.log('\nRoom: %s', room.name);
        console.log(room.toJSON());
    });

    cube.on('device', function(device) {
        console.log('\nDevice: %s%s', device.name, device.getRoom() ? ' in room ' + device.getRoom().name : '');
        console.log(device.toJSON());
        console.log(device.getConfig().toJSON());
        console.log(device.getStatus().toJSON());
    });

    cube.once('sync', function() {
        cube.close();
    });
});

API

node-max

max.connect([String|Object options])

Connect with a cube knowing it's ip address.

var max = require('@maexle/node-max'),
    cube = max.connect('192.168.0.10');

You can also pass an object instead:

var max = require('@maexle/node-max'),
    cube = max.connect({ip: '192.168.0.10'});

max.discover()

Discover MAX! cubes in your local network. Returns an EventEmitter which fires these events:

  • error: Something went wrong. You should get the error as the first argument.
  • cube: Heey, we found a cube. Answer object described below.
  • end: Discovery closed

The first argument for an cube event looks like this:

{
    "ip": "192.168.0.10",
    "serial": "JEQ0123456",
    "rf": "012EF0",
    "version": "1.1.3",
    "connect": function() {}
}

Use connect() to get the Cube Instance.

Tests

There are just very few tests, you can run them with

npm test

Copyright and license

Copyright (c) Sebastian Pekarek under the GNU GPL 3.0.