<!-- This is a transmitter node for lighting-type commands and the devices that receive tham -->
<script type="text/x-red" data-template-name="rfx-lights">
<div class="form-row node-input-port">
<label for="node-input-port"><i class="icon-bullhorn"></i> Serial Port</label>
<input type="text" id="node-input-port">
</div>
<div class="form-row node-input-topic">
<label for="node-input-topicSource"><i class="icon-envelope"></i> Address</label>
<select id="node-input-topicSource" style="width:73% !important">
<option value="msg">get address from message topic</option>
<option value="node">send all commands to the same address</option>
</select>
</div>
<div class="form-row" id="node-input-row-topic">
<label for="node-input-topic"></label>
<input type="text" id="node-input-topic" placeholder="protocol/device address/unit address">
</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">
RED.nodes.registerType('rfx-lights', {
category: 'output',
defaults: {
name: {name:""},
port: {type:"rfxtrx-port", required:true},
topicSource: { value:"msg", required:true },
topic: { value:"" }
},
color:"BurlyWood",
inputs:1,
outputs:0,
icon: "serial.png",
align: "right",
label: function() {
var rfxtrxNode = RED.nodes.node(this.rfxtrx);
return
this.name || (rfxtrxNode ? rfxtrxNode.label() : "rfx-lights");
},
labelStyle: function() {
},
oneditprepare: function() {
if (this.topicSource == null) {
if (this.topic == "") {
this.topicSource = "msg";
} else {
this.topicSource = "node";
}
}
$("#node-input-topicSource").change(function() {
var id = $("#node-input-topicSource option:selected").val();
if (id == "node") {
$("#node-input-row-topic").show();
} else {
$("#node-input-row-topic").hide();
}
});
$("#node-input-topicSource").val(this.topicSource);
$("#node-input-topicSource").change();
},
});
</script>