node-red-contrib-shelly
Version:
855 lines (726 loc) • 38.2 kB
HTML
<!-- Created by Karl-Heinz Wind -->
<!-- see also // https://shelly-api-docs.shelly.cloud/#common-http-api -->
<!-- GEN 1 ------------------------------------------------------------------------------------ -->
<!-- ------------------------------------------------------------------------------------------ -->
<script type="text/javascript">
RED.nodes.registerType('shelly-gen1-server', {
category: 'config',
defaults: {
port: { value: 0, validate: x => 0 <= Number(x) && Number(x) <= 65535 },
hostname: { value:"" },
hostip: { value:"" },
},
label: function () {
return this.port;
},
oneditprepare: function() {
// ip or hostname
let updateMode = function() {
let mode = $("#node-config-input-hostip").val();
if (mode == "hostname") {
$("#hostnameinput").show();
} else {
$("#hostnameinput").hide();
}
};
updateMode();
$("#node-config-input-hostip").change(updateMode);
let populateHostnames = function() {
$.getJSON('node-red-contrib-shelly-getipaddresses', function(ipAddresses) {
for (let i = 0; i <= ipAddresses.length; i++) {
let ipAddress = ipAddresses[i];
if (ipAddress !== undefined) {
$('#node-config-input-hostip').append('<option value="' + ipAddress + '">' + ipAddress + '</option>');
}
}
});
};
populateHostnames();
}
});
</script>
<script type="text/x-red" data-template-name="shelly-gen1-server">
<div class="form-row" style="min-width: 700px">
<div class="form-row">
<label for="node-config-input-port"><i class="fa fa-phone"></i> Port</label>
<input type="text" id="node-config-input-port" placeholder="(The network port to open)">
</div>
<div class="form-row">
<label for="node-config-input-hostip"><i class="fa fa-tag"></i> IP Address</label>
<select id="node-config-input-hostip" style="width:70%">
<option value="">Auto Detect</option>
<option value="hostname">Hostname</option>
</select>
</div>
<div class="form-row hidden" id="hostnameinput">
<label for="node-config-input-hostname"><i class="fa fa-tag"></i> Hostname</label>
<input type="text" id="node-config-input-hostname" placeholder="hostname of this node-red server.">
</div>
<div class="form-tips" style="width: auto"><b>Tip:</b> The hostname or IP should be set manually when for example running inside a docker container or behind NAT.</div>
</div>
</script>
<script type="text/x-red" data-help-name="shelly-gen1-server">
<p>A configuration node that runs a server on configured port to receive callbacks from the shelly.</p>
<h3>Details</h3>
<p>It opens a server on the configured port to receive callbacks.</p>
<p>The hostname is only needed if node-red is running behind a bridge or NAT e.g. in a docker image.</p>
</script>
<!-- ------------------------------------------------------------------------------------------ -->
<script type="text/javascript">
RED.nodes.registerType('shelly-gen1', {
category: 'Shelly',
color: '#319DD7',
defaults: {
hostname: { value:"" },
description: { value:"" },
mode: { value: "polling", required: true },
verbose: { value: false, required: true },
// callback
server: { value:"", type: "shelly-gen1-server", validate:function(v) {
let mode = $("#node-input-mode").val();
let ok = true;
if(mode == "callback"){
if(v.length == 0 || v === '_ADD_'){
ok = false;
}
}
return ok;
} },
outputmode: { value: "event", required: false },
uploadretryinterval: { value: 5000, required: false, validate:RED.validators.number() },
// polling
pollinginterval: { value: 5000, validate:RED.validators.number() },
pollstatus: { value: false, required: false },
getstatusoncommand: { value: true },
devicetype: { value: "", required: true},
devicetypemustmatchexactly : { value: true, required: false },
outputs: {value: 1},
},
credentials: {
username: { type: "text" },
password: { type: "password" },
},
inputs: 1,
outputs: 2,
icon: "shelly.png",
paletteLabel: "shelly gen 1",
label: function () {
return this.description || this.hostname || this.devicetype || "Shelly";
},
labelStyle: function() {
return this.description?"node_label_italic":"";
},
oneditprepare: function() {
debugger;
// the inputs edit field is always hidden.
$("#hiddeninputs").hide();
// polling or callback
var updateMode = function() {
var mode = $("#node-input-mode").val();
if (mode == "callback") {
$("#callback").show();
$("#polling").hide();
} else if (mode == "polling"){
$("#callback").hide();
$("#polling").show();
} else {
$("#callback").hide();
$("#polling").hide();
}
};
updateMode();
$("#node-input-mode").change(updateMode);
let populateDeviceTypes = function(devicetype) {
$.getJSON('node-red-contrib-shelly-getidevicetypesgen1', function(deviceTypeInfos) {
for (let i = 0; i <= deviceTypeInfos.length; i++) {
let deviceTypeInfo = deviceTypeInfos[i];
if (deviceTypeInfo !== undefined) {
$('#node-input-devicetype').append('<option value="' + deviceTypeInfo.deviceType + '">' + deviceTypeInfo.description + '</option>');
}
}
$('#node-input-devicetype').val(devicetype);
});
};
populateDeviceTypes(this.devicetype);
// enable 2nd output when measure device is selected
var updateDeviceType = function() {
var devicetype = $("#node-input-devicetype").val();
if (devicetype == 'Measure') {
$("#node-input-outputs").val(2);
} else {
$("#node-input-outputs").val(1);
}
if (devicetype == 'RGBW') {
$("#rgbw").show();
} else {
$("#rgbw").hide();
}
};
updateDeviceType();
$("#node-input-devicetype").change(updateDeviceType);
let getdevicetype = function() {
let hostname = $("#node-input-hostname").val();
if (hostname !== '') {
let parameters = {
hostname : hostname
}
$.getJSON('node-red-contrib-shelly-getshellyinfo', parameters, function(data) {
if(data.gen !== undefined){
if(data.gen == 1) {
$("#getdevicetypebuttonresult").text("Detected shelly " + data.model + "");
if(data.device !== undefined) {
$('#node-input-devicetype').val(data.device.model);
// gen 1 devices do not offer name nor id.
}
else {
$("#getdevicetypebuttonresult").text("Device could not be found in config. Please report device type in github.");
}
}
else {
$("#getdevicetypebuttonresult").text("Shelly gen " + data.gen + " is not supported by this node.");
}
}
else {
$("#getdevicetypebuttonresult").text("Shelly did not respond: " + hostname);
}
});
}
else{
$("#getdevicetypebuttonresult").text("Please enter a valid hostname first.");
}
}
$( '#getdevicetypebutton' ).click( function() {
getdevicetype();
});
}
});
</script>
<script type="text/x-red" data-template-name="shelly-gen1">
<div class="form-row">
<label for="node-input-hostname"><i class="fa fa-tag"></i> Hostname</label>
<input type="text" id="node-input-hostname" placeholder="The hostname or the IP address of the device">
</div>
<div class="form-row">
<label for="node-input-description"><i class="fa fa-comment"></i> Description</label>
<input type="text" id="node-input-description" placeholder="The description of the device (optional)">
</div>
<div class="form-row">
<label for="node-input-username"><i class="fa fa-user"></i> Username</label>
<input type="text" id="node-input-username" placeholder="Enter the username here (optional)">
</div>
<div class="form-row">
<label for="node-input-password"><i class="fa fa-key"></i> Password</label>
<input type="text" id="node-input-password" placeholder="Enter the password here (optional))">
</div>
<hr align="middle"/>
<div class="form-row">
<div class="form-row">
<label for="node-input-devicetype"><i class="fa fa-pencil"></i> Device Type</label>
<button id="getdevicetypebutton" type="button" class="red-ui-button" style="margin-left: 10px;">
<i class="fa fa-search"></i>
</button>
<div style="display: inline-block; position: relative; width: calc(80% - 105px); height: 19.1333px;">
<div style="position: absolute; left: 0; right: 0;">
<select id="node-input-devicetype" style="width: 100%">
<option value="Relay">Relay - Shelly1, 1PM, 1L, 2, 2.5, Plug(S/E/US), Uni</option>
<option value="Measure">Measure - Shelly EM, EM3</option>
<option value="Roller">Roller - Shelly 2, 2.5</option>
<option value="Dimmer">Dimmer - Shelly Dimmer 1/2, Duo, Vintage</option>
<option value="RGBW">RGBW - Shelly RGBW2, Bulb RGBW</option>
<option value="Thermostat">Thermostat - Shelly TRV</option>
<option value="Sensor">Sensor - Shelly Motion, Door, Window, H&T, Smoke, Flood, Gas</option>
<option value="Button">Button - Shelly Button, I3</option>
</select>
</div>
</div>
</div>
<div class="form-row">
<div class="form-tips" id='getdevicetypebuttonresult' style="width: auto"></div>
<div class="form-tips" id='getdevicetypebuttontip' style="width: auto">
<b>Tip:</b> You can auto detect the device type. Enter a valid IP address above and make sure the shelly is reachable and not sleeping. Press the search button next to the device type box.</div>
</div>
</div>
<div class="form-row" style="margin-left: 20px">
<div class="form-row">
<label for="node-input-devicetypemustmatchexactly"><i class="fa fa-exclamation"></i> Strict Mode</label>
<input type="checkbox" id="node-input-devicetypemustmatchexactly" style="display: inline-block; width: auto; vertical-align: top;">
</div>
<div class="form-tips" style="width: auto"><b>Tip:</b> If checked an error is created if the shelly is not yet supported. If you want that a new device is supported then create a new issue here: <a href="https://github.com/windkh/node-red-contrib-shelly/issues">Github</a></div>
</div>
<hr align="middle"/>
<div class="form-row">
<label for="node-input-mode"><i class="fa fa-link"></i> Mode</label>
<select id="node-input-mode" style="width:70%">
<option value="polling">Polling</option>
<option value="callback">Callback</option>
<option value="none">None</option>
</select>
</div>
<div class="form-row hidden" id="polling" style="background: #fbfbfb">
<label style="width: auto"><i class="fa fa-cogs"></i> Polling Options:</label>
<div class="form-row" style="margin-left: 20px">
<div class="form-row">
<label for="node-input-pollinginterval"><i class="fa fa-clock-o"></i> Ping Interval (ms)</label>
<input type="text" id="node-input-pollinginterval" placeholder="(Time in milliseconds. 0=off)">
</div>
<div class="form-row">
<label for="node-input-pollstatus"><i class="fa fa-repeat"></i> Status</label>
<input type="checkbox" id="node-input-pollstatus" style="display: inline-block; width: auto; vertical-align: top;"> Enable status output after each poll cycle
</div>
</div>
</div>
<div class="form-row hidden" id="callback" style="background: #fbfbfb">
<label style="width: auto"><i class="fa fa-cogs"></i> Callback Options:</label>
<div class="form-row" style="margin-left: 20px">
<div class="form-row">
<label for="node-input-server"><i class="fa fa-phone"></i> Server</label>
<input type="text" id="node-input-server" placeholder="Server">
</div>
<div class="form-row">
<label for="node-input-outputmode"><i class="fa fa-arrow-circle-right"></i> Output</label>
<select id="node-input-outputmode" style="width:70%">
<option value="event">Event</option>
<option value="status">Status</option>
</select>
</div>
<div class="form-row">
<label for="node-input-uploadretryinterval"><i class="fa fa-clock-o"></i> Upload Retry Interval (ms)</label>
<input type="text" id="node-input-uploadretryinterval" placeholder="(Time in milliseconds. 0=off)">
</div>
</div>
</div>
<hr align="middle"/>
<div class="form-row">
<label for="node-input-getstatusoncommand"><i class="fa fa-share"></i> Status</label>
<input type="checkbox" id="node-input-getstatusoncommand" style="display: inline-block; width: auto; vertical-align: top"> Enable status output after each command
</div>
<hr align="middle"/>
<div class="form-row" id="hiddeninputs">
<label for="node-input-outputs"><i class="fa fa-envelope"></i> Output Count</label>
<input type="text" id="node-input-outputs">
</div>
<hr align="middle"/>
<div class="form-row">
<label for="node-input-verbose"><i class="fa fa-pencil"></i> Verbose Logging</label>
<input type="checkbox" id="node-input-verbose" style="display: inline-block; width: auto; vertical-align: top;">
</div>
</script>
<script type="text/x-red" data-help-name="shelly-gen1">
<p>A node that controls a shelly generation 1 device.</p>
<h3>Configuration</h3>
<p>Hostname is the IP address or the hostname of the device.</p>
<p>Description of the device.</p>
<p>User is optional and must only be set if security is enabled.</p>
<p>Password is optional and must only be set if security is enabled.</p>
<p>Ping interval is the time between the status pollings.</p>
<p>Send status cyclically will send the status object on every poll cycle to the output.</p>
<h3>Inputs</h3>
<p>Empty payload for getting the status. See documentation for device specific input.</p>
<p><code>msg.payload</code></p>
<h3>Outputs</h3>
<p>1. Standard Ouput: status object.</p>
<p><code>msg.payload</code></p>
<p>Full status object is available at.</p>
<p><code>msg.status</code></p>
<p></p>
<p>2. CSV Ouput: The downloaded csv history for EM devices.</p>
<p><code>msg.payload</code></p>
</script>
<!-- GEN 2 ------------------------------------------------------------------------------------ -->
<!-- ------------------------------------------------------------------------------------------ -->
<script type="text/javascript">
RED.nodes.registerType('shelly-gen2-server', {
category: 'config',
defaults: {
port: { value: 0, validate: x => 0 <= Number(x) && Number(x) <= 65535 },
hostname: { value:"" },
hostip: { value:"" },
},
label: function () {
return this.port;
},
oneditprepare: function() {
// ip or hostname
let updateMode = function() {
let mode = $("#node-config-input-hostip").val();
if (mode == "hostname") {
$("#hostnameinput").show();
} else {
$("#hostnameinput").hide();
}
};
updateMode();
$("#node-config-input-hostip").change(updateMode);
let populateHostnames = function() {
$.getJSON('node-red-contrib-shelly-getipaddresses', function(ipAddresses) {
for (let i = 0; i <= ipAddresses.length; i++) {
let ipAddress = ipAddresses[i];
if (ipAddress !== undefined) {
$('#node-config-input-hostip').append('<option value="' + ipAddress + '">' + ipAddress + '</option>');
}
}
});
};
populateHostnames();
}
});
</script>
<script type="text/x-red" data-template-name="shelly-gen2-server">
<div class="form-row" style="min-width: 700px">
<div class="form-row">
<label for="node-config-input-port"><i class="fa fa-phone"></i> Port</label>
<input type="text" id="node-config-input-port" placeholder="(The network port to open)">
</div>
<div class="form-row">
<label for="node-config-input-hostip"><i class="fa fa-tag"></i> IP Address</label>
<select id="node-config-input-hostip" style="width:70%">
<option value="">Auto Detect</option>
<option value="hostname">Hostname</option>
</select>
</div>
<div class="form-row hidden" id="hostnameinput">
<label for="node-config-input-hostname"><i class="fa fa-tag"></i> Hostname</label>
<input type="text" id="node-config-input-hostname" placeholder="hostname of this node-red server.">
</div>
<div class="form-tips" style="width: auto"><b>Tip:</b> The hostname or IP should be set manually when for example running inside a docker container or behind NAT.</div>
</div>
</script>
<script type="text/x-red" data-help-name="shelly-gen2-server">
<p>A configuration node that runs a server on configured port to receive callbacks from the shelly.</p>
<h3>Details</h3>
<p>It opens a server on the configured port to receive callbacks.</p>
<p>The hostname is only needed if node-red is running behind a bridge or NAT e.g. in a docker image.</p>
</script>
<!-- ------------------------------------------------------------------------------------------ -->
<script type="text/javascript">
RED.nodes.registerType('shelly-gen2', {
category: 'Shelly',
color: '#6C95CE',
defaults: {
hostname: { value:"" },
description: { value:"" },
mode: { value: "polling", required: true },
verbose: { value: false, required: true },
// callback
server: { value:"", type: "shelly-gen2-server", validate:function(v) {
let mode = $("#node-input-mode").val();
let ok = true;
if(mode == "callback"){
if(v.length == 0 || v === '_ADD_'){
ok = false;
}
}
return ok;
} },
outputmode: { value: "event", required: false },
uploadretryinterval: { value: 5000, required: false, validate:RED.validators.number() },
// polling
pollinginterval: { value: 5000, validate:RED.validators.number() },
pollstatus: { value: false, required: false },
getstatusoncommand: { value: true },
devicetype: { value: "", required: true},
devicetypemustmatchexactly : { value: true, required: false },
captureblutooth : { value: false, required: false },
outputs: {value: 1},
},
credentials: {
password: { type: "password" },
},
inputs: 1,
outputs: 1,
icon: "shelly2.png",
paletteLabel: "shelly gen 2+",
label: function () {
return this.description || this.hostname || this.devicetype || "Shelly";
},
labelStyle: function() {
return this.description?"node_label_italic":"";
},
oneditprepare: function() {
debugger;
// polling or callback
var updateMode = function() {
var mode = $("#node-input-mode").val();
if (mode == "callback") {
$("#callback").show();
$("#polling").hide();
} else if (mode == "polling"){
$("#callback").hide();
$("#polling").show();
} else {
$("#callback").hide();
$("#polling").hide();
}
};
updateMode();
$("#node-input-mode").change(updateMode);
let populateDeviceTypes = function(devicetype) {
$.getJSON('node-red-contrib-shelly-getidevicetypesgen2', function(deviceTypeInfos) {
for (let i = 0; i <= deviceTypeInfos.length; i++) {
let deviceTypeInfo = deviceTypeInfos[i];
if (deviceTypeInfo !== undefined) {
$('#node-input-devicetype').append('<option value="' + deviceTypeInfo.deviceType + '">' + deviceTypeInfo.description + '</option>');
}
}
$('#node-input-devicetype').val(devicetype);
});
};
populateDeviceTypes(this.devicetype);
let updateDeviceType = function() {
let devicetype = $("#node-input-devicetype").val();
// TODO: for future usage. e.g. give a measure node 2 outputs
};
updateDeviceType();
$("#node-input-devicetype").change(updateDeviceType);
let getdevicetype = function() {
let hostname = $("#node-input-hostname").val();
if (hostname !== '') {
let parameters = {
hostname : hostname
}
$.getJSON('node-red-contrib-shelly-getshellyinfo', parameters, function(data) {
if(data.gen !== undefined){
if(data.gen >= 2) {
$("#getdevicetypebuttonresult").text("Detected shelly " + data.model + "");
if(data.device !== undefined) {
$('#node-input-devicetype').val(data.device.model);
if(data.name) {
$('#node-input-description').val(data.name);
}else if(data.id) {
$('#node-input-description').val(data.id);
}
else{
// gen 1 devices do not offer name nor id.
}
}
else {
$("#getdevicetypebuttonresult").text("Device could not be found in config. Please report device type in github.");
}
}
else {
$("#getdevicetypebuttonresult").text("Shelly gen " + data.gen + " is not supported by this node.");
}
}
else {
$("#getdevicetypebuttonresult").text("Shelly did not respond: " + hostname);
}
});
}
else{
$("#getdevicetypebuttonresult").text("Please enter a valid hostname first.");
}
}
$( '#getdevicetypebutton' ).click( function() {
getdevicetype();
});
}
});
</script>
<script type="text/x-red" data-template-name="shelly-gen2">
<div class="form-row">
<label for="node-input-hostname"><i class="fa fa-tag"></i> Hostname</label>
<input type="text" id="node-input-hostname" placeholder="The hostname or the IP address of the device">
</div>
<div class="form-row">
<label for="node-input-description"><i class="fa fa-comment"></i> Description</label>
<input type="text" id="node-input-description" placeholder="The description of the device (optional)">
</div>
<div class="form-row">
<label for="node-input-password"><i class="fa fa-key"></i> Password</label>
<input type="text" id="node-input-password" placeholder="Enter the password here (optional))">
</div>
<hr align="middle"/>
<div class="form-row">
<div class="form-row">
<label for="node-input-devicetype"><i class="fa fa-pencil"></i> Device Type</label>
<button id="getdevicetypebutton" type="button" class="red-ui-button" style="margin-left: 10px;">
<i class="fa fa-search"></i>
</button>
<div style="display: inline-block; position: relative; width: calc(80% - 105px); height: 19.1333px;">
<div style="position: absolute; left: 0; right: 0;">
<select id="node-input-devicetype" style="width: 100%">
<option value="Relay">Relay - any relay</option>
<option value="Button">Button - any button</option>
<option value="Sensor">Sensor - any sensor</option>
<option value="Measure">Measure - any measure device</option>
<option value="Dimmer">Dimmer - any dimmer</option>
<option value="Roller">Roller - any roller/shutter</option>
<option value="BluGateway">BLU-Gateway - any bluetooth gatweway</option>
</select>
</div>
</div>
</div>
<div class="form-row">
<div class="form-tips" id='getdevicetypebuttonresult' style="width: auto"></div>
<div class="form-tips" id='getdevicetypebuttontip' style="width: auto">
<b>Tip:</b> You can auto detect the device type. Enter a valid IP address above and make sure the shelly is reachable and not sleeping. Press the search button next to the device type box.</div>
</div>
</div>
<div class="form-row" style="margin-left: 20px">
<div class="form-row">
<label for="node-input-devicetypemustmatchexactly"><i class="fa fa-exclamation"></i> Strict Mode</label>
<input type="checkbox" id="node-input-devicetypemustmatchexactly" style="display: inline-block; width: auto; vertical-align: top;">
</div>
<div class="form-tips" style="width: auto"><b>Tip:</b> If checked an error is created if the shelly is not yet supported. If you want that a new device is supported then create a new issue here: <a href="https://github.com/windkh/node-red-contrib-shelly/issues">Github</a></div>
</div>
<hr align="middle"/>
<div class="form-row">
<label for="node-input-mode"><i class="fa fa-link"></i> Mode</label>
<select id="node-input-mode" style="width:70%">
<option value="polling">Polling</option>
<option value="callback">Callback</option>
<option value="none">None</option>
</select>
</div>
<div class="form-tips" style="width: auto"><b>Tip:</b> For BluGateway please choose callback with event as output!</div>
<div class="form-row hidden" id="polling" style="background: #fbfbfb">
<label style="width: auto"><i class="fa fa-cogs"></i> Polling Options:</label>
<div class="form-row" style="margin-left: 20px">
<div class="form-row">
<label for="node-input-pollinginterval"><i class="fa fa-clock-o"></i> Ping Interval (ms)</label>
<input type="text" id="node-input-pollinginterval" placeholder="(Time in milliseconds. 0=off)">
</div>
<div class="form-row">
<label for="node-input-pollstatus"><i class="fa fa-repeat"></i> Status</label>
<input type="checkbox" id="node-input-pollstatus" style="display: inline-block; width: auto; vertical-align: top;"> Enable status output after each poll cycle
</div>
</div>
</div>
<div class="form-row hidden" id="callback" style="background: #fbfbfb">
<label style="width: auto"><i class="fa fa-cogs"></i> Callback Options:</label>
<div class="form-row" style="margin-left: 20px">
<div class="form-row">
<label for="node-input-server"><i class="fa fa-phone"></i> Server</label>
<input type="text" id="node-input-server" placeholder="Server">
</div>
<div class="form-row">
<label for="node-input-outputmode"><i class="fa fa-arrow-circle-right"></i> Output</label>
<select id="node-input-outputmode" style="width:70%">
<option value="event">Event</option>
<option value="status">Status</option>
</select>
</div>
<div class="form-row">
<label for="node-input-uploadretryinterval"><i class="fa fa-clock-o"></i> Upload Retry Interval (ms)</label>
<input type="text" id="node-input-uploadretryinterval" placeholder="(Time in milliseconds. 0=off)">
</div>
<div class="form-row">
<label for="node-input-captureblutooth"><i class="fa fa-bluetooth"></i> Blutooth</label>
<input type="checkbox" id="node-input-captureblutooth" style="display: inline-block; width: auto; vertical-align: top;"> Install blutooth gateway script
</div>
<div class="form-tips" style="width: auto"><b>Tip:</b> If checked a blutooth gateway script is installed. Is automatically activated for BLU gateway.</div>
</div>
</div>
<hr align="middle"/>
<div class="form-row">
<label for="node-input-getstatusoncommand"><i class="fa fa-share"></i> Status</label>
<input type="checkbox" id="node-input-getstatusoncommand" style="display: inline-block; width: auto; vertical-align: top"> Enable status output after each command
</div>
<hr align="middle"/>
<div class="form-row">
<label for="node-input-verbose"><i class="fa fa-pencil"></i> Verbose Logging</label>
<input type="checkbox" id="node-input-verbose" style="display: inline-block; width: auto; vertical-align: top;">
</div>
</script>
<script type="text/x-red" data-help-name="shelly-gen2">
<p>A node that controls a shelly generation 2 device.</p>
<h3>Configuration</h3>
<p>Hostname is the IP address or the hostname of the device.</p>
<p>Description of the device.</p>
<p>Password is optional and must only be set if security is enabled.</p>
<p>Ping interval is the time between the status pollings.</p>
<p>Send status cyclically will send the status object on every poll cycle to the output.</p>
<h3>Inputs</h3>
<p>Empty payload for getting the status. See documentation for device specific input.</p>
<p><code>msg.payload</code></p>
<h3>Outputs</h3>
<p>1. Standard Ouput: status object.</p>
<p><code>msg.payload</code></p>
<p>Full status object is available at.</p>
<p><code>msg.status</code></p>
</script>
<!-- CLOUD ------------------------------------------------------------------------------------ -->
<!-- ------------------------------------------------------------------------------------------ -->
<script type="text/javascript">
RED.nodes.registerType('shelly-cloud-server', {
category: 'config',
defaults: {
description: { value:"" },
},
credentials: {
serveruri: { type: "text" },
authkey: { type: "password" },
},
label: function () {
return this.description || "Shelly Cloud";
}
});
</script>
<script type="text/x-red" data-template-name="shelly-cloud-server">
<div class="form-row" style="min-width: 700px">
<div class="form-row">
<label for="node-config-input-description"><i class="fa fa-tag"></i> Description</label>
<input type="text" id="node-config-input-description" placeholder="Description of this configuration (optional).">
</div>
<div class="form-row">
<label for="node-config-input-serveruri"><i class="fa fa-user"></i> Server URI</label>
<input type="text" id="node-config-input-serveruri" placeholder="https://">
</div>
<div class="form-row">
<label for="node-config-input-authkey"><i class="fa fa-key"></i> Authentication Key</label>
<input type="text" id="node-config-input-authkey" placeholder="Enter the auth key here">
</div>
</div>
</script>
<script type="text/x-red" data-help-name="shelly-cloud-server">
<p>A configuration node that can be used by several shelly cloud nodes.</p>
</script>
<!-- ------------------------------------------------------------------------------------------ -->
<script type="text/javascript">
RED.nodes.registerType('shelly-cloud', {
category: 'Shelly',
color: '#AEC860',
defaults: {
server: { value:"", type: "shelly-cloud-server", required: true },
description: { value:"" },
outputs: {value: 1},
},
inputs: 1,
outputs: 1,
icon: "shellycloud.png",
paletteLabel: "shelly cloud",
label: function () {
return this.description || "Shelly";
},
labelStyle: function() {
return this.description?"node_label_italic":"";
},
oneditprepare: function() {
}
});
</script>
<script type="text/x-red" data-template-name="shelly-cloud">
<div class="form-row">
<label for="node-input-server"><i class="fa fa-phone"></i> Server</label>
<input type="text" id="node-input-server" placeholder="Server">
</div>
<div class="form-row">
<label for="node-input-description"><i class="fa fa-comment"></i> Description</label>
<input type="text" id="node-input-description" placeholder="The description of the device (optional)">
</div>
</script>
<script type="text/x-red" data-help-name="shelly-cloud">
<p>A node that controls a shelly cloud device.</p>
<h3>Configuration</h3>
<p>Description of the device.</p>
<p>Server URI of shelly cloud.</p>
<p>Authentication Key of your account.</p>
<h3>Inputs</h3>
<p>See example in example folder.</p>
<p><code>msg.payload</code></p>
<h3>Outputs</h3>
<p>1. Standard Ouput: status object.</p>
<p><code>msg.payload</code></p>
<p>Full status object is available at.</p>
<p><code>msg.status</code></p>
</script>