mirror of
https://github.com/node-red/node-red-nodes.git
synced 2023-10-10 13:36:58 +02:00
Added duino support for RC switches and added error handling to heatmiser
This commit is contained in:
parent
7a987b2317
commit
0a4b2a4876
48
hardware/duino/97-duino.html
Normal file
48
hardware/duino/97-duino.html
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
<!--
|
||||||
|
Copyright 2013 IBM Corp.
|
||||||
|
|
||||||
|
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="duino">
|
||||||
|
<div class="form-row">
|
||||||
|
<label for="node-input-name"><i class="icon-tag"></i> Pin</label>
|
||||||
|
<input type="text" id="node-input-pin" placeholder="10">
|
||||||
|
</div>
|
||||||
|
<div class="form-tips">Expects a msg.payload of the signal to send to the RC switch</div>
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<script type="text/x-red" data-help-name="duino">
|
||||||
|
<p>Duino node built on top of the duino library.</p>
|
||||||
|
<p>INPUT - Expects a msg.payload of the signal to send to the RC switch.</p>
|
||||||
|
<h3>RC Switch</h3>
|
||||||
|
<p><pre>{inputType: "RC", rcCode: 8DIGITCODE, on : true/false}</pre></p>
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<script type="text/javascript">
|
||||||
|
RED.nodes.registerType('duino',{
|
||||||
|
category: 'advanced-function',
|
||||||
|
color:"#3fadb5",
|
||||||
|
defaults: {
|
||||||
|
pin: {value:""}
|
||||||
|
},
|
||||||
|
inputs:1,
|
||||||
|
icon: "arduino.png",
|
||||||
|
label: function() {
|
||||||
|
return this.name||"duino";
|
||||||
|
},
|
||||||
|
labelStyle: function() {
|
||||||
|
return this.name?"node_label_italic":"";
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</script>
|
58
hardware/duino/97-duino.js
Normal file
58
hardware/duino/97-duino.js
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
/**
|
||||||
|
* Copyright 2013 IBM Corp.
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
**/
|
||||||
|
|
||||||
|
var RED = require(process.env.NODE_RED_HOME+"/red/red");
|
||||||
|
|
||||||
|
var duino = require("duino");
|
||||||
|
var util = require('util');
|
||||||
|
|
||||||
|
function DuinoNode(n) {
|
||||||
|
var DEBUG = true;
|
||||||
|
RED.nodes.createNode(this,n);
|
||||||
|
this.pin = n.pin || "10";
|
||||||
|
node = this;
|
||||||
|
this.board = new duino.Board();
|
||||||
|
|
||||||
|
|
||||||
|
this.on("input", function(message) {
|
||||||
|
if (typeof(message.payload) == "string") {
|
||||||
|
message.payload = JSON.parse(message.payload);
|
||||||
|
}
|
||||||
|
// Send message as RC triState
|
||||||
|
if (message.payload.inputType === "RC") {
|
||||||
|
var rcCode = message.payload.rcCode;
|
||||||
|
util.log("RCCode = "+ rcCode);
|
||||||
|
if (rcCode.length != 8) {
|
||||||
|
util.log("[duino] - Error, code : "+rcCode+ "was not 8 digits long!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var rcRef = new duino.RC({
|
||||||
|
board: node.board,
|
||||||
|
pin: parseInt(node.pin, 10)
|
||||||
|
});
|
||||||
|
|
||||||
|
if (message.payload.on) {
|
||||||
|
rcRef.triState(message.payload.rcCode + "FFFF");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
rcRef.triState(message.payload.rcCode + "FFF0");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
RED.nodes.registerType("duino",DuinoNode);
|
@ -50,7 +50,9 @@ function HeatmiserNode(n) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
this.read = function() {
|
this.read = function() {
|
||||||
|
if (node.hm) {
|
||||||
node.hm.read_device();
|
node.hm.read_device();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!this.currentStatus) {
|
if (!this.currentStatus) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user