spejsiot/spejsiot/endpoints/OutputEndpoint.cpp

16 lines
449 B
C++

#include <endpoints/OutputEndpoint.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;
}
digitalWrite(pin, inverted ^ currentValue);
notify("on", currentValue ? "true" : "false");
return 200;
}