Skip to content

Commit

Permalink
Merge pull request #17 from ryanjohnsontv/scene-passthrough
Browse files Browse the repository at this point in the history
Add Scene Node ID Passthrough
  • Loading branch information
ryanjohnsontv authored Sep 27, 2021
2 parents d3d6065 + b2dbb4d commit 9f9518c
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 5 deletions.
10 changes: 10 additions & 0 deletions nodes/inovelli-scene-manager.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
switchtype: { value: "LZW30" },
outputs: { value: 1 },
labels: { value: ["Please select a Switch Type"] },
passthrough: { default: false },
},
inputs: 1,
outputs: 1,
Expand Down Expand Up @@ -126,6 +127,8 @@
<label for="node-input-zwave"><i class="icon-tag"></i>Z-Wave Integration</label>
<select name="node-input-zwave" id="node-input-zwave">
<option value="zwave_js">Z-Wave JS</option>
<option value="ozw">Open Z-Wave</option>
<option value="zwave">Z-Wave</option>
</select>
</div>
<div class="form-row nodeid-input">
Expand All @@ -141,6 +144,10 @@
<option value="LZW45">Lightstrip & Controller Kit (LZW45)</option>
</select>
</div>
<div class="form-row">
<label for="node-input-passthrough"><i class="icon-tag"></i>Node ID Passthrough</label>
<input type="checkbox" id="node-input-passthrough">
</div>
</script>

<script type="text/x-red" data-help-name="inovelli-scene-manager">
Expand All @@ -154,5 +161,8 @@

<dt>Switch Type<span class="property-type">number|string</span></dt>
<dd>Determines which Inovelli switch is being used. (LZW30-SN, LZW31-SN, LZW36, LZW45)</dd>

<dt>Node ID Passthrough<span class="property-type">boolean</span></dt>
<dd>Disables specifying a node id, node will instead pass through all value/scene notifications (ideal when your Z-Wave network uses ALL of the same switch)</dd>
</dl>
</script>
23 changes: 19 additions & 4 deletions nodes/inovelli-scene-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,25 @@ module.exports = function (RED) {
function InovelliSceneManager(config) {
RED.nodes.createNode(this, config);
var node = this;
const { zwave, nodeid, switchtype, outputs } = config;
const { zwave, nodeid, switchtype, outputs, passthrough } = config;
this.zwave = zwave;
this.nodeid = nodeid;
this.switchtype = switchtype;
this.outputs = parseInt(outputs, 10);
this.passthrough = passthrough;

node.on("input", (msg) => {
const { zwave: presetZwave, nodeid, switchtype, outputs } = node;
const {
zwave: presetZwave,
nodeid,
switchtype,
outputs,
passthrough,
} = node;
const payload = msg.payload;
const domain = payload.event.domain;
const event_type = payload.event_type;
const nodes = nodeid.split(',').map(Number);
const nodes = nodeid.split(",").map(Number);
const node_id = parseInt(payload.event.node_id);
const event_types = {
zwave_js: "zwave_js_value_notification",
Expand Down Expand Up @@ -43,7 +50,15 @@ module.exports = function (RED) {
}
validateDomain(presetZwave, domain);

if (nodes.includes(node_id) === true && error === 0) {
function validateNodeID() {
if (!nodes.includes(node_id) && !passthrough) {
error++;
}
}

validateNodeID();

if (error === 0) {
const LZW30Map = {
0: {
button: 2,
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "node-red-contrib-ha-inovelli-manager",
"version": "0.1.0",
"version": "0.1.1",
"repository": {
"type": "git",
"url": "https://github.com/ryanjohnsontv/node-red-contrib-ha-inovelli-manager.git"
Expand Down

0 comments on commit 9f9518c

Please sign in to comment.