UNPKG

node-red-contrib-bean

Version:
58 lines (49 loc) 2.52 kB
<!-- Copyright 2014 Punch Throguh Design. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> <script type="text/x-red" data-template-name="bean temp"> <div class="form-row node-input-bean"> <label for="node-input-bean"><i class="fa fa-random"></i> Bean</label> <input type="text" id="node-input-bean"> </div> <div class="form-row"> <label for="node-input-name"><i class="fa fa-tag"></i> Name</label> <input type="text" id="node-input-name" placeholder="Name"> </div> </script> <script type="text/x-red" data-help-name="bean temp"> <p>Sending any message to this node will trigger a request to read a Bean&#39;s ambient temperature.</p> <p>When the temperature has been successfully read, this node outputs an object called <b>msg</b> containing a <b>msg.topic</b> and <b>msg.payload</b>. msg.topic is set to <b>"temp"</b> and msg.payload is an <b>integer</b> representing temperature in <b>degrees C.</b></p> </script> <script type="text/javascript"> RED.nodes.registerType('bean temp',{ category: 'LightBlue Bean-input', // the palette category defaults: { // defines the editable properties of the node name: {name:""}, bean: {type:"bean",required:true} // along with default values. }, inputs:1, // set the number of inputs - only 0 or 1 outputs:1, // set the number of outputs - 0 to n color: "#3FADB5", // set the icon (held in icons dir below where you save the node) icon: "temp.png", // saved in icons/myicon.png paletteLabel: "temperature", label: function() { // sets the default label contents var beanNode = RED.nodes.node(this.bean); return this.name||((beanNode?beanNode.label():"Bean") + " temp"); }, labelStyle: function() { // sets the class to apply to the label return this.name?"node_label_italic":""; } }); </script>