Skip to content

Commit

Permalink
Merge pull request #29 from Achronite/develop
Browse files Browse the repository at this point in the history
v0.3.5 Release
  • Loading branch information
Achronite authored Feb 2, 2020
2 parents e393e17 + 15d9608 commit 8c97878
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 34 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ If you have any issues with the code, particularly if your board is not initiali
0.3.0|10 Jan 20|Major change - Switched to use node.js Native API (N-API) for calling C functions, and split off new node module. Added a new node to support MiHome Radiator Valve, along with a separate thread for monitoring that implements caching and dynamic polling. This version requires node.js v10+.
0.3.2|17 Jan 20|Added node v10+ dependency (via 'engines'). Fixed issue with teaching OOK devices, and added 'off' button. Added troubleshooting section to docs.
0.3.4|22 Jan 20|Fixed zone 0 switch all devices. Tested Energenie 4-way gang. Updates to GUI tip shown for eTRV. Made emit monitor device specific to improve performance.
0.3.5|02 Feb 20|Improve error handling for board failure.

## Dependencies

Expand All @@ -259,4 +260,4 @@ https://github.com/Achronite/node-red-contrib-energenie-ener314rt/issues



@Achronite - January 2020 - v0.3.4 Beta
@Achronite - January 2020 - v0.3.5 Beta
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"name": "node-red-contrib-energenie-ener314rt",
"version": "0.3.4",
"version": "0.3.5",
"description": "Node-red module for energenie ENER314-RT board for raspberry pi",
"dependencies": {
"energenie-ener314rt": "^0.3.2"
"energenie-ener314rt": "^0.3.3"
},
"engines": {
"node" : ">=10.0.0"
Expand Down
2 changes: 0 additions & 2 deletions red/ener314-rt.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,6 @@ module.exports = function (RED) {

// Call discovery function
var devices = ener314rt.openThingsDeviceList(false);
//var devices = JSON.parse(ref.readCString(buf, 0));
//res.end(JSON.stringify(devices));
res.end(devices);
});

Expand Down
4 changes: 2 additions & 2 deletions red/ook-switch.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
})

.fail(function () {
RED.notify("Something went wrong teaching the device", "error")
RED.notify("Cannot communicate with device, check board", "error")
})
}

Expand All @@ -42,7 +42,7 @@
})

.fail(function () {
RED.notify("Something went wrong teaching the device", "error")
RED.notify("Cannot communicate with device, check board", "error")
})
}

Expand Down
49 changes: 27 additions & 22 deletions red/ook-switch.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,12 @@ module.exports = function (RED) {
// Override the zone set in the node properties
zone = msg.payload.zone;
}
// Set default zone if we still dont have one
/*
if ( zone === "" || zone == null || zone === undefined ) {
// Energenie 'random' 20 bit address is 0x6C6C6 # 0110 1100 0110 1100 0110
zone = 0; // 0 indicates the C code will use the default zone
}
*/

// Check Switch Number
if (switchNum < 0 || switchNum > 6 || isNaN(switchNum)) {
this.error("SwitchNum err: " + switchNum + " (" + typeof (switchNum) + ")");
}


// Check Switch State (default to off)
var switchState = false;
if (typeof msg.payload == typeof true)
Expand All @@ -68,17 +60,20 @@ module.exports = function (RED) {
xmits = Number(msg.payload.repeat);

// Invoke C function to do the send
ener314rt.ookSwitch(zone, switchNum, switchState, xmits);
switch (switchState) {
case true:
node.status({ fill: "green", shape: "dot", text: "ON " + zone + ":" + switchNum });
break;
case false:
node.status({ fill: "red", shape: "ring", text: "OFF " + zone + ":" + switchNum });
break;
if (ener314rt.ookSwitch(zone, switchNum, switchState, xmits) == 0) {
switch (switchState) {
case true:
node.status({ fill: "green", shape: "dot", text: "ON " + zone + ":" + switchNum });
break;
case false:
node.status({ fill: "red", shape: "ring", text: "OFF " + zone + ":" + switchNum });
break;
}
// return payload unchanged
node.send(msg);
} else {
node.status({ fill: "grey", shape: "dot", text: "ERROR" });
}
// return payload unchanged
node.send(msg);

});

Expand All @@ -93,14 +88,24 @@ module.exports = function (RED) {
RED.httpAdmin.get("/ook/teach", function (req, res) {
var zone = Number(req.query.zone) || 0;
var switchNum = Number(req.query.switchNum);
ener314rt.ookSwitch(zone, switchNum, true, 20);
res.sendStatus(200);
var ret = ener314rt.ookSwitch(zone, switchNum, true, 20);
if (ret < 0) {
console.error(`[ERROR] ener314rt - OOK teach failed ${ret}`);
res.sendStatus(500);
} else {
res.sendStatus(200);
}
});

RED.httpAdmin.get("/ook/off", function (req, res) {
var zone = Number(req.query.zone) || 0;
var switchNum = Number(req.query.switchNum);
ener314rt.ookSwitch(zone, switchNum, false, 20);
res.sendStatus(200);
var ret = ener314rt.ookSwitch(zone, switchNum, false, 20);
if (ret < 0) {
console.error(`[ERROR] ener314rt - OOK off failed ${ret}`);
res.sendStatus(500);
} else {
res.sendStatus(200);
}
});
}
2 changes: 1 addition & 1 deletion red/openThings-trv.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ module.exports = function (RED) {
}

// send on decoded OpenThings message as is
//console.log(`sending payload`);
console.log(`sending payload for ${deviceId} ts=${OTmsg.timestamp}`);
node.send({ 'payload': OTmsg });
});

Expand Down

0 comments on commit 8c97878

Please sign in to comment.