node-red-contrib-zwave-js
Version:
The most powerful, high performing and highly polished Z-Wave node for Node-RED based on Z-Wave JS. If you want a fully featured Z-Wave framework in your Node-RED instance, you have found it.
154 lines (139 loc) • 3.68 kB
HTML
<script type="text/javascript">
const ZWJSDeviceNodeSettings = {
category: 'ZWave JS',
color: 'rgb(46,145,205)',
defaults: {
name: {
value: 'ZWave Device',
required: true
},
runtimeId: {
value: '',
required: true,
type: 'zwavejs-runtime'
},
nodeMode: {
value: 'All',
required: true
},
filteredNodeId: {
value: '',
required: false
},
dataMode: {
value: 'SR',
required: true
},
outputs: { value: 1 },
inputs: { value: 1 }
},
inputs: 1,
outputs: 1,
icon: 'Device.svg',
label: function () {
return this.name;
},
paletteLabel: 'Device',
oneditprepare: Prep,
oneditsave: Save
};
RED.nodes.registerType('zwavejs-device', ZWJSDeviceNodeSettings);
function Save() {
switch ($('#node-input-dataMode').val()) {
case 'SR':
this.inputs = 1;
this.outputs = 1;
break;
case 'R':
this.inputs = 0;
this.outputs = 1;
break;
case 'S':
this.inputs = 1;
this.outputs = 0;
break;
}
}
function Prep() {
const self = this;
const Get = (ID) => {
$.getJSON(`zwave-js/ui/${ID}/CONTROLLER/getNodes`, (data) => {
if (data.callSuccess) {
const Nodes = data.response
.filter((N) => !N.isControllerNode)
.map((N) => ({
value: `${N.nodeId}`,
label: `${N.nodeId} - ${N.nodeLocation || 'No Location'} - ${N.nodeName || 'No Name'}`
}));
$('#node-input-filteredNodeId').typedInput({
type: 'nodes',
types: [
{
value: 'nodes',
multiple: true,
options: Nodes
}
]
});
} else {
alert(data.response);
}
});
};
if (self.runtimeId) {
Get(self.runtimeId);
}
$('#node-input-runtimeId').on('change', function () {
Get($(this).val());
});
$('#node-input-nodeMode').on('change', function () {
if ($(this).val() === 'All') {
$('#node-input-filteredNodeId-div').fadeOut(150);
} else {
$('#node-input-filteredNodeId-div').fadeIn(150);
}
});
}
</script>
<!-- prettier-ignore -->
<script type="text/x-red" data-template-name="zwavejs-device">
<h3>Basic</h3>
<hr />
<div class="form-row">
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
<input type="text" id="node-input-name">
</div>
<div class="form-row">
<label for="node-input-runtimeId"><i class="fa fa-cog"></i> Runtime</label>
<input type="text" id="node-input-runtimeId">
</div>
<h3>Operating Mode</h3>
<hr />
<div class="form-row">
<label for="node-input-dataMode"><i class="fa fa-exchange"></i> Data Mode</label>
<select id="node-input-dataMode">
<option value="SR">Send/Receive</option>
<option value="S">Send</option>
<option value="R">Receive</option>
</select>
</div>
<div class="form-row">
<label for="node-input-nodeMode"><i class="fa fa-th-large"></i> Receive For</label>
<select id="node-input-nodeMode">
<option value="All">All Nodes</option>
<option value="Multiple">Selected Nodes</option>
</select>
</div>
<div class="form-row" id="node-input-filteredNodeId-div">
<label for="node-input-filteredNodeId"><i class="fa fa-list-ol"></i> Nodes</label>
<input type="text" id="node-input-filteredNodeId">
</div>
<div class="form-tips" id="node-tip">
<strong>Note : </strong>To use Message Broadcasting set <code>nodeId</code> to an array of Nodes.<br />
<strong>Message Broadcasting</strong> is only supported for use with <code>setValue</code>.
</div>
</script>
<!-- prettier-ignore -->
<script type="text/markdown" data-help-name="zwavejs-device">
<p>A ZWave JS device allowing control of one or many devices</p>
</script>