node-red-contrib-globalcache
Version:
Global Cache (iTach & iTach Flex) for node-red
160 lines (150 loc) • 5.93 kB
HTML
<script type="text/x-red" data-template-name="globalcache-controller">
<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" placeholder="Name">
</div>
<div class="form-row">
<label for="node-config-input-host"><i class="icon-bookmark"></i> gc Host</label>
<input type="text" id="node-config-input-host">
</div>
<div class="form-row">
<label for="node-config-input-port"><i class="icon-bookmark"></i> gc Port</label>
<input type="text" id="node-config-input-port">
</div>
<div class="form-row">
<label for="node-config-input-mode"><i class="icon-bookmark"></i> gc Mode</label>
<select id="node-config-input-mode">
<option value="request-disconnect">request-disconnect</option>
<option value="always-connected">always-connected</option>
</select>
</div>
</script>
<script type="text/x-red" data-template-name="globalcache-out">
<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-controller"><i class="icon-bookmark"></i> Controller</label>
<input type="text" id="node-input-controller">
</div>
<div class="form-row">
<label for="node-input-unit_number"><i class="icon-bookmark"></i> Unit number</label>
<input type="text" id="node-input-unit_number">
</div>
<div class="form-row">
<label for="node-input-output"><i class="icon-bookmark"></i> Output</label>
<input type="text" id="node-input-output">
</div>
<div class="form-row">
<label for="node-input-gccommand"><i class="icon-bookmark"></i> Command</label>
<select id="node-input-gccommand">
<option value="empty">no cmd</option>
<option value="sendir">infrared</option>
<option value="setstate">relay</option>
</select>
</div>
</script>
<script type="text/x-red" data-template-name="globalcache-in">
<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-controller"><i class="icon-bookmark"></i> Controller</label>
<input type="text" id="node-input-controller">
</div>
</script>
<script type="text/x-red" data-help-name="globalcache-out">
<p>
Use this to <b>send</b> telegrams via an gc daemon connected to a Global Cache device.<br/>
<b>msg.payload</b> must be a JavaScript object or a string
</p>
<p>
For example: <code>setstate,1:1,1</code> or <code>{"serial": "setstate,1:1,1"}</code>
</p>
<p>
If one specify three parameters: unit_number (optional, in fact), output and command, than all incoming string commands will be transformed into GlobalCache` packet: <code>[command],[unit_number]:[output],[command]</code>
<p>
<p>
For example, let configs be:
<ul>
<li>unit_number is empty</li>
<li>output is 3</li>
<li>and command is <code>sendir</code></li>
</ul>
<br/>
And command (inside of <code>msg.payload</code>) is <code>1,38000,1,1,105,84,22,3800</code>.
<br/>
Than ready packet (it will be sent into GC device) looks like:
<code>sendir,1:3,1,38000,1,1,105,84,22,3800</code>
</p>
<br/>
<p>
Send command in CCF mode:
</p>
<p>
<b>msg.payload</b> should contain code in CCF mode<br/>
<b>msg.format</b> must be equal <code>ccf</code> or <code>hex</code>
</p>
<br/>
<p>
Send command without Queue of commands:
</p>
<p>
<b>msg.justnow</b> should contain <code>true</code> value
</p>
</script>
<script type="text/x-red" data-help-name="globalcache-in">
<p>Use this to <b>inject</b> flows from GlobalCache device<br/>
</script>
<script type="text/javascript">
RED.nodes.registerType('globalcache-controller', {
category: 'config',
defaults: {
name: {value: ""},
host: {value: "127.0.0.1", required: true},
port: {value: 4998, required: false, validate: RED.validators.number()},
mode: {value: "request-disconnect", required: true}
},
label: function () {
return (this.name || 'gc' ) + "@" + this.host + ":" + this.port;
}
});
</script>
<script type="text/javascript">
RED.nodes.registerType('globalcache-out', {
category: 'output',
color: '#26b050',
defaults: {
name: {value: ""},
controller: {value: "", type: "globalcache-controller"},
unit_number: {value: "1", required: false},
output: {value: "1", required: false},
gccommand: {value: "empty", required: true}
},
inputs: 1,
outputs: 0,
align: 'right',
icon: "bridge-dash.png",
label: function () {
return (this.groupaddr || this.name || "gc");
}
});
</script>
<script type="text/javascript">
RED.nodes.registerType('globalcache-in', {
category: 'input',
color: '#26b050',
defaults: {
name: {value: ""},
controller: {value: "", type: "globalcache-controller"}
},
inputs: 0,
outputs: 1,
icon: "bridge-dash.png",
label: function () {
return (this.groupaddr || this.name || "gc");
}
});
</script>