Skip to content

Commit

Permalink
Support API level 2. (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mike Stegeman authored Mar 2, 2018
1 parent f46df01 commit c051f21
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 11 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "zwave-adapter",
"version": "0.3.1",
"version": "0.3.2",
"description": "Z-Wave adapter plugin for Mozilla IoT Gateway",
"main": "index.js",
"keywords": [
Expand Down Expand Up @@ -31,7 +31,7 @@
"moziot": {
"api": {
"min": 1,
"max": 1
"max": 2
},
"enabled": true,
"plugin": true,
Expand Down
13 changes: 12 additions & 1 deletion zwave-adapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,21 @@

const path = require('path');
const fs = require('fs');
const Adapter = require('../adapter');
const ZWaveNode = require('./zwave-node');
const SerialPort = require('serialport');
const zwaveClassifier = require('./zwave-classifier');

let Adapter;
try {
Adapter = require('../adapter');
} catch (e) {
if (e.code !== 'MODULE_NOT_FOUND') {
throw e;
}

Adapter = require('gateway-addon').Adapter;
}

var ZWaveModule;

const DEBUG = false;
Expand Down
12 changes: 11 additions & 1 deletion zwave-classifier.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,19 @@

'use strict';

const Constants = require('../addon-constants');
const ZWaveProperty = require('./zwave-property');

let Constants;
try {
Constants = require('../addon-constants');
} catch (e) {
if (e.code !== 'MODULE_NOT_FOUND') {
throw e;
}

Constants = require('gateway-addon').Constants;
}

// See; http://wiki.micasaverde.com/index.php/ZWave_Command_Classes for a
// complete list of command classes.

Expand Down
21 changes: 16 additions & 5 deletions zwave-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,23 @@

'use strict';

var Device = require('../device');
var utils = require('../utils');
let Device, Utils;
try {
Device = require('../device');
Utils = require('../utils');
} catch (e) {
if (e.code !== 'MODULE_NOT_FOUND') {
throw e;
}

const gwa = require('gateway-addon');
Device = gwa.Device;
Utils = gwa.Utils;
}

var padLeft = utils.padLeft;
var padRight = utils.padRight;
var repeatChar = utils.repeatChar;
var padLeft = Utils.padLeft;
var padRight = Utils.padRight;
var repeatChar = Utils.repeatChar;

let BASIC_STR = [
'???',
Expand Down
15 changes: 13 additions & 2 deletions zwave-property.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,19 @@

'use strict';

const Deferred = require('../deferred');
const Property = require('../property');
let Deferred, Property;
try {
Deferred = require('../deferred');
Property = require('../property');
} catch (e) {
if (e.code !== 'MODULE_NOT_FOUND') {
throw e;
}

const gwa = require('gateway-addon');
Deferred = gwa.Deferred;
Property = gwa.Property;
}

class ZWaveProperty extends Property {
constructor(device, name, propertyDescr, valueId,
Expand Down

0 comments on commit c051f21

Please sign in to comment.