node-red-contrib-netpie
Version:
Node-RED module for connecting to NETPIE IoT Platform
169 lines (152 loc) • 6.42 kB
HTML
<script type="text/javascript">
RED.nodes.registerType('devicestatus',{
category: 'netpie',
color: '#90cc90',
paletteLabel: "status",
defaults: {
name : {value: "status"},
deviceconfig: {
value: "Default",
type: "deviceconfig"
},
active: {value: true},
topics: {value: ""}
},
inputs:1,
outputs:1,
icon: "font-awesome/fa-heartbeat",
button: {
enabled: function() {
return true
},
visible: function() {
return true
},
onclick: function() {
var label = (this.name||this.body);
var node = this;
$.ajax({
url: "inject/"+this.id,
type:"POST",
success: function(resp, textStatus, xhr) {
RED.notify(node._("reload status and shadow",{label:label}),"success");
},
error: function(jqXHR,textStatus,errorThrown) {
}
});
}
},
outputLabels: ["status"],
label: function() {
return this.name||"status";
},
oneditprepare: function() {
this.editor = RED.editor.createEditor({
id: 'node-input-topics-editor',
value: $("#node-input-topics").val(),
globals: {
msg:true,
context:true,
RED: true,
util: true,
flow: true,
global: true,
console: true,
Buffer: true,
setTimeout: true,
clearTimeout: true,
setInterval: true,
clearInterval: true
}
});
},
oneditsave: function() {
$("#node-input-topics").val(this.editor.getValue());
this.editor.destroy();
delete this.editor;
},
oneditcancel: function() {
this.editor.destroy();
delete this.editor;
}
});
</script>
<script type="text/x-red" data-help-name="devicestatus">
<p>The Status node monitors and reports the connection status and operational state of NETPIE/NEXPIE devices. It provides real-time visibility into device connectivity and health.</p>
<h3>Configuration</h3>
<dl class="message-properties">
<dt>Active</dt>
<dd>Enable/disable the node operation</dd>
<dt>Name</dt>
<dd>The name of the node displayed in the flow</dd>
<dt>Device</dt>
<dd>Select the device configuration to monitor status for</dd>
</dl>
<h3>Input</h3>
<p>Accepts trigger messages to manually check device status:</p>
<dl class="message-properties">
<dt>Any message</dt>
<dd>Triggers an immediate status check and refresh</dd>
<dt>action <span class="property-type">string</span></dt>
<dd>Optional. Specific action to perform (e.g., "refresh", "ping")</dd>
</dl>
<h3>Output</h3>
<p>Outputs device status information from NETPIE platform:</p>
<dl class="message-properties">
<dt>payload <span class="property-type">object</span></dt>
<dd>The complete status object containing all device information as returned by NETPIE API</dd>
<dt>payload.deviceid <span class="property-type">string</span></dt>
<dd>Unique device identifier from NETPIE portal</dd>
<dt>payload.groupid <span class="property-type">string</span></dt>
<dd>Group identifier that the device belongs to</dd>
<dt>payload.projectid <span class="property-type">string</span></dt>
<dd>Project identifier in NETPIE platform</dd>
<dt>payload.status <span class="property-type">number</span></dt>
<dd>Device status code: 1 = online/active, 0 = offline/inactive</dd>
<dt>payload.enabled <span class="property-type">boolean</span></dt>
<dd>Whether the device is enabled in the project</dd>
</dl>
<h3>Status Information</h3>
<p>The payload object typically contains:</p>
<pre>{
"deviceid": "17a30f78-27da-9173-92b2-652ca0b20cf8",
"groupid": "G713335850114",
"projectid": "P060627955206",
"status": 1,
"enabled": true
}</pre>
<h3>Status Properties</h3>
<ul>
<li><b>deviceid</b>: Unique device identifier from NETPIE portal</li>
<li><b>groupid</b>: Group identifier that the device belongs to</li>
<li><b>projectid</b>: Project identifier in NETPIE platform</li>
<li><b>status</b>: Device status code (1 = active/online, 0 = inactive/offline)</li>
<li><b>enabled</b>: Whether the device is enabled in the project (true/false)</li>
</ul>
<h3>Button Function</h3>
<p>The node includes a button that can be clicked to manually reload the current device status and shadow data for immediate status checking.</p>
<h3>Notes</h3>
<ul>
<li>This node provides read-only status monitoring</li>
<li>Status updates are received automatically when device state changes</li>
<li>The node requires proper device configuration with valid credentials</li>
<li>Useful for implementing device health monitoring and alerting systems</li>
<li>Can be combined with dashboard nodes to create visual status indicators</li>
<li>Status information depends on the device's implementation and platform capabilities</li>
</ul>
</script>
<script type="text/x-red" data-template-name="devicestatus">
<div class="form-row">
<label for="node-input-active"><i class="icon-cog"></i> Active</label>
<input type="checkbox" id="node-input-active" style="margin-left:5px; vertical-align:top; width:auto;">
Enabled
</div>
<div class="form-row">
<label for="node-input-name"><i class="icon-tag"></i> Name</label>
<input type="text" id="node-input-name" placeholder="Name">
</div>
<div class="form-row">
<label for="node-input-deviceconfig"><i class="icon-cog"></i> Device </label>
<input type="text" id="node-input-deviceconfig">
</div>
</script>