Automatic mode is set; instead of ON
This commit is contained in:
parent
595fbbc3da
commit
7567a4ef07
39
src/main.cpp
39
src/main.cpp
@ -299,23 +299,30 @@ void loopHandler()
|
|||||||
bool ledHandler(const HomieRange& range, const String& value) {
|
bool ledHandler(const HomieRange& range, const String& value) {
|
||||||
if (range.isRange) return false; // only one switch is present
|
if (range.isRange) return false; // only one switch is present
|
||||||
|
|
||||||
mSomethingReceived = true; // Stop animation
|
Homie.getLogger() << "Received: " << (value) << endl;
|
||||||
|
if (value.equals("250,250,250")) {
|
||||||
int sep1 = value.indexOf(',');
|
mSomethingReceived = false; // enable animation again
|
||||||
int sep2 = value.indexOf(',', sep1 + 1);
|
ledStripNode.setProperty(NODE_AMBIENT).send(value);
|
||||||
if ((sep1 > 0) && (sep2 > 0)) {
|
|
||||||
int red = value.substring(0,sep1).toInt(); /* OpenHAB hue (0-360°) */
|
|
||||||
int green = value.substring(sep1 + 1, sep2).toInt(); /* OpenHAB saturation (0-100%) */
|
|
||||||
int blue = value.substring(sep2 + 1, value.length()).toInt(); /* brightness (0-100%) */
|
|
||||||
|
|
||||||
uint8_t r = (red * 255) / 250;
|
|
||||||
uint8_t g = (green *255) / 250;
|
|
||||||
uint8_t b = (blue *255) / 250;
|
|
||||||
uint32_t c = strip.Color(r,g,b);
|
|
||||||
strip.fill(c);
|
|
||||||
strip.show();
|
|
||||||
ledStripNode.setProperty(NODE_AMBIENT).send(String(r) + "," + String(g) + "," + String(b));
|
|
||||||
return true;
|
return true;
|
||||||
|
} else {
|
||||||
|
mSomethingReceived = true; // Stop animation
|
||||||
|
|
||||||
|
int sep1 = value.indexOf(',');
|
||||||
|
int sep2 = value.indexOf(',', sep1 + 1);
|
||||||
|
if ((sep1 > 0) && (sep2 > 0)) {
|
||||||
|
int red = value.substring(0,sep1).toInt();
|
||||||
|
int green = value.substring(sep1 + 1, sep2).toInt();
|
||||||
|
int blue = value.substring(sep2 + 1, value.length()).toInt();
|
||||||
|
|
||||||
|
uint8_t r = (red * 255) / 250;
|
||||||
|
uint8_t g = (green *255) / 250;
|
||||||
|
uint8_t b = (blue *255) / 250;
|
||||||
|
uint32_t c = strip.Color(r,g,b);
|
||||||
|
strip.fill(c);
|
||||||
|
strip.show();
|
||||||
|
ledStripNode.setProperty(NODE_AMBIENT).send(value);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user