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:
parent
937f26da41
commit
d090df94c5
@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user