node-red-contrib-simple-gate
Advanced tools
Comparing version 0.2.0 to 0.2.1
54
gate.js
@@ -47,29 +47,33 @@ /** | ||
if (msg.topic !== undefined && msg.topic.toLowerCase() === node.controlTopic) { | ||
switch (msg.payload.toLowerCase()) { | ||
case node.openCmd: | ||
state = 'open'; | ||
break; | ||
case node.closeCmd: | ||
state = 'closed'; | ||
break; | ||
case node.toggleCmd: | ||
if (state === 'open') { | ||
if (typeof msg.payload != 'string'){ | ||
node.error('Command must be a string'); | ||
} else { | ||
switch (msg.payload.toLowerCase()) { | ||
case node.openCmd: | ||
state = 'open'; | ||
break; | ||
case node.closeCmd: | ||
state = 'closed'; | ||
} else { | ||
state = 'open'; | ||
} | ||
break; | ||
case node.defaultCmd: | ||
state = node.defaultState; | ||
break; | ||
default: | ||
node.error('Invalid command'); | ||
break; | ||
break; | ||
case node.toggleCmd: | ||
if (state === 'open') { | ||
state = 'closed'; | ||
} else { | ||
state = 'open'; | ||
} | ||
break; | ||
case node.defaultCmd: | ||
state = node.defaultState; | ||
break; | ||
default: | ||
node.error('Invalid command'); | ||
break; | ||
} | ||
// Save state | ||
context.set('state',state); | ||
// Show status | ||
status = (state === 'open') ? openStatus:closedStatus; | ||
node.status(status); | ||
node.send(null); | ||
} | ||
// Save state | ||
context.set('state',state); | ||
// Show status | ||
status = (state === 'open') ? openStatus:closedStatus; | ||
node.status(status); | ||
node.send(null); | ||
} | ||
@@ -76,0 +80,0 @@ // Transmit message |
{ | ||
"name" : "node-red-contrib-simple-gate", | ||
"version" : "0.2.0", | ||
"version" : "0.2.1", | ||
"description" : "A gate node for node-RED", | ||
@@ -5,0 +5,0 @@ "license" : "Apache-2.0", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
245441
114