UNPKG

node-red-contrib-azure-iot-central

Version:

Receive Json from previous node, send it to IoT Central provisioned device (Scope ID, Device ID, SAS Key). Supports mqtt, amqp, http. Supports commands, reported and desired properties.

117 lines (112 loc) 5.41 kB
<script type="text/javascript"> RED.nodes.registerType('Azure IoT Central',{ category: 'function', color: '#0072C6', defaults: { scopeid: {value:"", required: true}, deviceid: {value:"", required: true}, primarykey: {value:"", required: false}, command1: {value:""}, command2: {value:""}, command3: {value:""}, command4: {value:""}, command5: {value:""}, transport: {value: "mqtt"}, auth: {value: "sas"}, //certfile: {value: "", validate:RED.validators.regex(/pem$/)}, certfile: {value: "", required: false}, certkeyfile: {value: "", required: false}, passwordi: {value: "", required: false} }, inputs:1, outputs:1, icon: "iot-central.png", label: function() { return this.name||"Azure IoT Central"; }, oneditprepare: function() { function toglecertfilesinput(){ if ($('#node-input-auth').val() === 'sas') { $(".form-row-certfile").hide(); $(".form-row-certkeyfile").hide(); $(".form-row-primarykey").show(); $(".form-row-passwordi").hide(); } else{ $(".form-row-certfile").show(); $(".form-row-certkeyfile").show(); $(".form-row-passwordi").show(); $(".form-row-primarykey").hide(); } }; toglecertfilesinput(); $('#node-input-auth').on("change", function() { toglecertfilesinput(); }); } }); </script> <script type="text/html" data-template-name="Azure IoT Central"> <div class="form-row"> <label data-i18n="node-input-transport">Transport</label> <select id="node-input-transport" style="width:70%;"> <option value="mqtt" data-i18n="red-iot-central.mqtt">MQTT</option> <option value="amqp" data-i18n="red-iot-central.amqp">AMQP</option> <option value="https" data-i18n="red-iot-central.https">HTTPS</option> </select> </div> <div class="form-row"> <label data-i18n="node-input-auth">Authentication</label> <select id="node-input-auth" style="width:70%;"> <option value="sas" data-i18n="red-iot-central.sas">SAS</option> <option value="x509" data-i18n="red-iot-central.x509">X.509</option> </select> </div> <div class="form-row form-row-certfile"> <label for="node-input-certfile"><i class="icon-tag"></i>Device Cert File</label> <input type="text" id="node-input-certfile" placeholder="Device Cert file (.pem)"> </div> <div class="form-row form-row-certkeyfile"> <label for="node-input-certkeyfile"><i class="icon-tag"></i>Device Cert Key File</label> <input type="text" id="node-input-certkeyfile" placeholder="Device Cert key file (.pem)"> </div> <div class="form-row form-row-passwordi"> <label for="node-input-passwordi"><i class="icon-tag"></i>Password</label> <input type="text" id="node-input-passwordi" placeholder="Password"> </div> <div class="form-row"> <label for="node-input-scopeid"><i class="icon-tag"></i>Scope ID</label> <input type="text" id="node-input-scopeid" placeholder="Scope ID"> </div> <div class="form-row"> <label for="node-input-deviceid"><i class="icon-tag"></i>Device ID</label> <input type="text" id="node-input-deviceid" placeholder="Device ID"> </div> <div class="form-row form-row-primarykey"> <label for="node-input-primarykey"><i class="icon-tag"></i>Primary Key</label> <input type="text" id="node-input-primarykey" placeholder="Primary Key"> </div> <div class="form-row"> <label for="node-input-command1"><i class="icon-tag"></i>Command Name</label> <input type="text" id="node-input-command1" placeholder="Insert the command name of your model interface "> </div> <div class="form-row"> <label for="node-input-command2"><i class="icon-tag"></i>Command Name</label> <input type="text" id="node-input-command2" placeholder="Insert the command name of your model interface "> </div> <div class="form-row"> <label for="node-input-command3"><i class="icon-tag"></i>Command Name</label> <input type="text" id="node-input-command3" placeholder="Insert the command name of your model interface "> </div> <div class="form-row"> <label for="node-input-command4"><i class="icon-tag"></i>Command Name</label> <input type="text" id="node-input-command4" placeholder="Insert the command name of your model interface "> </div> <div class="form-row"> <label for="node-input-command5"><i class="icon-tag"></i>Command Name</label> <input type="text" id="node-input-command5" placeholder="Insert the command name of your model interface "> </div> </script> <script type="text/html" data-help-name="Azure IoT Central"> <p>A simple node that helps to connect to Azure IoT Central</p> </script>