UNPKG

@ekristoffe/node-red-contrib-nature-remo

Version:
137 lines (129 loc) 4.92 kB
<script type="text/x-red" data-template-name="nature-credentials"> <div class="form-row"> <label style="margin-left: 20px;" for="node-config-input-token"> Home name</label> <input type="text" id="node-config-input-name"> </div> <div class="form-row"> <p style="margin-top: 30px;">You might want to grab an API token from <a href="https://home.nature.global" target="_blank" style="text-decoration:underline;">home.nature.global</a></p> </div> <div class="form-row"> <label style="margin-left: 20px;" for="node-config-input-token"> Token</label> <input type="password" id="node-config-input-token"> </div> </script> <script type="text/javascript"> console.log("registering nature remo config node"); RED.nodes.registerType("nature-credentials", { category: "config", defaults: { name: { value: "" }, token: { type: "password", required: true, }, }, label: function () { if (this.name) { return this.name; } else { return "Nature: " + this.id; } }, exportable: false, oneditsave: function () { var trimFields = ["token"]; // Just in case any whitespace has crept in with the copy-paste of the fields trimFields.forEach(function (field) { var v = $("#node-config-input-" + field).val(); v = v.trim(); $("#node-config-input-" + field).val(v); }); }, }); </script> <!-- ************************************************************* --> <script type="text/x-red" data-template-name="nature-control"> <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-client_id"><i class="icon-tag"></i> Nature Home</label> <input type="text" id="node-input-natureCreds" placeholder="Add nature credentials"> </div> <div class="form-row"> <label for="node-input-nickname"><i class="icon-tag"></i> Appliance nickname</label> <input type="text" id="node-input-nickname" placeholder="Nickname"> </div> </script> <script type="text/javascript"> console.log("registering nature remo control node"); RED.nodes.registerType("nature-control", { category: "Nature-Remo", color: "#669966", defaults: { name: { value: "" }, natureCreds: { type: "nature-credentials", required: true }, nickname: { value: "" }, }, inputs: 1, outputs: 1, icon: "feed.png", }); </script> <!-- ************************************************************* --> <script type="text/javascript"> console.log("registering nature get appliances"); RED.nodes.registerType("nature-get-appliances", { category: "Nature-Remo", color: "#669966", defaults: { natureCreds: { type: "nature-credentials", required: true }, name: { value: "" }, }, inputs: 1, outputs: 1, icon: "feed.png", label: function () { return "get appliances"; }, }); </script> <script type="text/x-red" data-template-name="nature-get-appliances"> <div class="form-row"> <label for="node-input-client_id"><i class="icon-tag"></i> Nature Home</label> <input type="text" id="node-input-natureCreds" placeholder="Add nature credentials"> </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> </script> <!-- ************************************************************* --> <script type="text/javascript"> console.log("registering nature get devices"); RED.nodes.registerType("nature-get-devices", { category: "Nature-Remo", color: "#669966", defaults: { natureCreds: { type: "nature-credentials", required: true }, name: { value: "" }, }, inputs: 1, outputs: 1, icon: "feed.png", label: function () { return "get devices"; }, }); </script> <script type="text/x-red" data-template-name="nature-get-devices"> <div class="form-row"> <label for="node-input-client_id"><i class="icon-tag"></i> Nature Home</label> <input type="text" id="node-input-natureCreds" placeholder="Add nature credentials"> </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> </script>