1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Arduino output - ensure string/number payloads handled

A change to tighten the type checking meant passing a string
'0' or '1' no longer matched the tests for numeric 0 or 1.
This commit is contained in:
Nick O'Leary 2015-04-14 23:14:13 +01:00
parent 937f26da41
commit d090df94c5

View File

@ -121,10 +121,10 @@ module.exports = function(RED) {
node.board.pinMode(node.pin, node.state); node.board.pinMode(node.pin, node.state);
node.on("input", function(msg) { node.on("input", function(msg) {
if (node.state === "OUTPUT") { if (node.state === "OUTPUT") {
if ((msg.payload === true)||(msg.payload == 1)||(msg.payload.toString().toLowerCase() == "on")) { if ((msg.payload === true)||(msg.payload.toString() == 1)||(msg.payload.toString().toLowerCase() == "on")) {
node.board.digitalWrite(node.pin, true); node.board.digitalWrite(node.pin, true);
} }
if ((msg.payload === false)||(msg.payload === 0)||(msg.payload.toString().toLowerCase() == "off")) { if ((msg.payload === false)||(msg.payload.toString() == 0)||(msg.payload.toString().toLowerCase() == "off")) {
node.board.digitalWrite(node.pin, false); node.board.digitalWrite(node.pin, false);
} }
} }