@smappee/node-red-contrib-smappee
Version:
Smappee Node-RED contains Smappee nodes and example flows
142 lines (126 loc) • 5.07 kB
HTML
<!-- Node 'device-config' -->
<script type="text/x-red" data-template-name="device-config">
<div class="form-row">
<label for="node-config-input-serial"><i class="fa fa-tag"></i> <span>Serial</span></label>
<input type="text" id="node-config-input-serial">
</div>
<div class="form-row">
<label for="node-config-input-host"><i class="fa fa-globe"></i> <span>Host</span></label>
<input type="text" id="node-config-input-host" placeholder="Leave empty to autofill if possible">
</div>
<div class="form-row">
<label for="node-config-input-name"><i class="fa fa-tag"></i> <span>Name</span></label>
<input type="text" id="node-config-input-name" placeholder="Name">
</div>
</script>
<script type="text/x-red" data-help-name="device-config">
<p>A configuration node for a Smappee device.</p>
<h3>Serial</h3>
<p>Serial number of your Smappee device. This can be found on a sticker on the device.</p>
<h3>Host</h3>
<p>Only required if your network does not support DNS name resolution. Alternatively you can find the
device's IP address in the Smappee app.</p>
<h3>Name</h3>
<p>Type in the name of the device manually or keep the default name.</p>
</script>
<script type="text/javascript">
RED.nodes.registerType('device-config', {
category: 'config',
defaults: {
name: {value: ''},
serial: {value: '', required: true},
host: {value: ''},
},
label: function() {
return this.name || 'smappee:' + this.serial;
},
labelStyle: function() {
return this.name ? 'node_label_italic' : '';
},
});
</script>
<!-- Node 'switch-config' -->
<script type="text/x-red" data-template-name="switch-config">
<div class="form-row">
<label for="node-config-input-uuid"><i class="fa fa-tag"></i> <span>Switch ID</span></label>
<input type="text" id="node-config-input-uuid">
</div>
<div class="form-row">
<label for="node-config-input-name"><i class="fa fa-tag"></i> <span>Name</span></label>
<input type="text" id="node-config-input-name" placeholder="Name">
</div>
</script>
<script type="text/x-red" data-help-name="switch-config">
<p>A configuration node for a Smappee Switch.</p>
<h3>Switch ID</h3>
<p>Identifier of the Smappee Switch, starts with 1 if you only have a single Smappee Switch. Increments with 1 per Smappee Switch you have configured.</p>
<h3>Name</h3>
<p>Type in the name of the Smappee Switch manually or keep the default name.</p>
</script>
<script type="text/javascript">
RED.nodes.registerType('switch-config', {
category: 'config',
defaults: {
name: {value: ''},
uuid: {value: '', required: true},
},
label: function() {
return this.name || 'switch:' + this.uuid;
},
labelStyle: function() {
return this.name ? 'node_label_italic' : '';
},
});
</script>
<!-- Node 'device' -->
<script type="text/x-red" data-template-name="device">
<div class="form-row">
<label for="node-input-device"><i class="fa fa-globe"></i> <span>Smappee</span></label>
<input type="text" id="node-input-device">
</div>
<div class="form-row">
<label for="node-input-name"><i class="fa fa-tag"></i> <span>Name</span></label>
<input type="text" id="node-input-name" placeholder="Name">
</div>
</script>
<script type="text/x-red" data-help-name="device">
<p>Device node that provides config information about the Smappee device and returns it as an object.</p>
<h3>Outputs</h3>
<p>A message is returned once on start-up through <code>msg.payload</code> values:</p>
<dl class="message-properties">
<dt>utcTimeStamp <span class="property-type">number</span></dt>
<dd>Numeric value of the current date and time on the device.</dd>
<dt>deviceUuid <span class="property-type">string</span></dt>
<dd>Device UUID.</dd>
<dt>serialNumber <span class="property-type">string</span></dt>
<dd>Serial number of the device.</dd>
<dt>serviceLocationUuid <span class="property-type">string</span></dt>
<dd>Service location UUID.</dd>
<dt>serviceLocationId <span class="property-type">string</span></dt>
<dd>Unique identifier of the service location.</dd>
<dt>firmwareVersion <span class="property-type">string</span></dt>
<dd>Currently running firmware version.</dd>
<dt>aggregationPeriodSeconds <span class="property-type">number</span></dt>
<dd>Duration of the aggregation period, by default 300 seconds or 5 minutes.</dd>
</dl>
</script>
<script type="text/javascript">
RED.nodes.registerType('device', {
category: 'smappee device',
color: '#99c031',
defaults: {
name: {value: ''},
device: {value: '', required: true, type: 'device-config'},
},
inputs: 0,
outputs: 1,
icon: 'inject.png',
label: function() {
const device = RED.nodes.node(this.device);
return this.name || 'device' + (device ? `:${device.host}` : '');
},
labelStyle: function() {
return this.name ? 'node_label_italic' : '';
},
});
</script>