node-red-contrib-bean
Version:
Node-red node for the LightBlue Bean
64 lines (55 loc) • 2.75 kB
HTML
<!--
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 led">
<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 led">
<p>This node allows you to set the <b>red</b>, <b>green</b>, and <b>blue</b> values of a Bean's LED.</p>
<p><br/><b>Option 1:</b> </p>
<p>Input a message with a string payload containing one of the four options: "Red", "Green", "Blue", or "Off"</p>
<p><br/><b>Option 2:</b> </p>
<p>Input a message with a string payload containing three <b>comma separated</b> integer values each between <b>0 and 255</b> inclusive. The integers represent red, green, and blue in that order.</p>
<p><br/><b>Examples:</b> </p>
<p>"0,255,0" is entirely green</p>
<p>"255,0,255" is purple</p>
</script>
<script type="text/javascript">
RED.nodes.registerType('bean led',{
category: 'LightBlue Bean-output', // 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:0, // set the number of outputs - 0 to n
color: "#3FADB5",
// set the icon (held in icons dir below where you save the node)
icon: "light.png", // saved in icons/myicon.png
paletteLabel: "rgb led",
label: function() { // sets the default label contents
var beanNode = RED.nodes.node(this.bean);
return this.name||((beanNode?beanNode.label():"Bean") + " LED");
},
labelStyle: function() { // sets the class to apply to the label
return this.name?"node_label_italic":"";
},
align: 'right'
});
</script>