UNPKG

node-red-contrib-google-home-notify-volume-adjustable

Version:

Node-Red nodes for google-home-notify library. With this node you can cast any String (up to 200 chars) to any google cast device.

125 lines (116 loc) 4.27 kB
<script type="text/javascript"> RED.nodes.registerType('googlehome-config-node', { category: 'config', defaults: { ipaddress: { value: "", required: true }, name: { value: "" }, language: { value: "en" } }, label: function () { return this.name || this.ipaddress; }, oneditprepare: function () { var node = this; var options = $("#node-input-language"); //Calling the API built by NodeJS code $.getJSON('/languages', function (languages) { $.each(languages, function (l, language) { options.append($("<option />").val(language.key).text(language.value)); options.val(node.language); }); }); try { $("#node-config-input-ipaddress").autocomplete( "destroy" ); } catch(err) { } $("#node-config-lookup-ipaddress").click(function() { $("#node-config-lookup-ipaddress-icon").removeClass('fa-search'); $("#node-config-lookup-ipaddress-icon").addClass('spinner'); $("#node-config-lookup-ipaddress").addClass('disabled'); $.getJSON('ipaddresses',function(data) { $("#node-config-lookup-ipaddress-icon").addClass('fa-search'); $("#node-config-lookup-ipaddress-icon").removeClass('spinner'); $("#node-config-lookup-ipaddress").removeClass('disabled'); var ipaddresses = []; $.each(data, function(i, ip){ ipaddresses.push(ip); }); $("#node-config-input-ipaddress").autocomplete({ source:ipaddresses, minLength:0, close: function( event, ui ) { $("#node-config-input-ipaddress").autocomplete( "destroy" ); } }).autocomplete("search",""); }); }); }, oneditsave: function () { var node = this; node.language = $("#node-input-language").val(); } }); </script> <script type="text/x-red" data-template-name="googlehome-config-node"> <div class="form-row"> <label for="node-config-input-ipaddress"><i class="icon-bookmark"></i> IP Adress</label> <input type="text" id="node-config-input-ipaddress" style="width:60%;" placeholder="192.168.xxx.xxx"/> <a id="node-config-lookup-ipaddress" class="btn"><i id="node-config-lookup-ipaddress-icon" class="fa fa-search"></i></a> </div> <div class="form-row"> <label for="node-config-input-name"><i class="icon-tag"></i> Name</label> <input type="text" id="node-config-input-name" style="width:60%;" placeholder="Google Home Mini"/> </div> <div class="form-row"> <label for="node-input-language"><i class="fa fa-globe"></i> Language</label> <select id="node-input-language" style="width:60%;"> <option value="en"> English</option> </select> </div> <!-- <div class="form-row"> <label for="node-config-input-language"><i class="icon-bookmark"></i> Language</label> <input type="text" id="node-config-input-language"> </div> --> </script> <!-- ###############################################################################################################--> <script type="text/x-red" data-template-name="googlehome-notify"> <div class="form-row"> <label for="node-input-server"><i class="fa fa-globe"></i> IP Adress</label> <input type="text" id="node-input-server"> </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="Google Home Notifier" style="width: 70%;"> </div> <div class="form-row"> <p> announcement volume can be set with <b>msg.emitVolume</b> </br> value has to be in range between 0-100 </p> </div> </script> <script type="text/javascript"> RED.nodes.registerType('googlehome-notify', { category: 'output', color: '#fff', defaults: { server: { value: "", type: "googlehome-config-node" }, name: { value: "" } }, inputs: 1, outputs: 0, label: function () { return this.configname || this.name || "Google Home Notify"; } }); </script>