spejsiot-sonoff_pow/soft/src/spejsiot/endpoints/OutputEndpoint.cpp

21 lines
659 B
C++

#include <endpoints/OutputEndpoint.h>
#include <SpejsNode.h>
EndpointResult OutputEndpoint::onValue(String property, String value) {
if (value == "1" or value == "on" or value == "true") {
currentValue = 1;
} else if (value == "0" or value == "off" or value == "false") {
currentValue = 0;
} else {
return 400;
}
if (currentValue != (parent->statusLED.blinkOn > parent->statusLED.blinkRate/2)) {
parent->statusLED.blinkOn = parent->statusLED.blinkRate - parent->statusLED.blinkOn;
}
digitalWrite(pin, inverted ^ currentValue);
notify("on", currentValue ? "true" : "false");
return 200;
}