Automatic mode is set; instead of ON

This commit is contained in:
Ollo 2021-11-27 14:56:19 +01:00
parent 595fbbc3da
commit 7567a4ef07

View File

@ -299,14 +299,20 @@ 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
Homie.getLogger() << "Received: " << (value) << endl;
if (value.equals("250,250,250")) {
mSomethingReceived = false; // enable animation again
ledStripNode.setProperty(NODE_AMBIENT).send(value);
return true;
} else {
mSomethingReceived = true; // Stop animation mSomethingReceived = true; // Stop animation
int sep1 = value.indexOf(','); int sep1 = value.indexOf(',');
int sep2 = value.indexOf(',', sep1 + 1); int sep2 = value.indexOf(',', sep1 + 1);
if ((sep1 > 0) && (sep2 > 0)) { if ((sep1 > 0) && (sep2 > 0)) {
int red = value.substring(0,sep1).toInt(); /* OpenHAB hue (0-360°) */ int red = value.substring(0,sep1).toInt();
int green = value.substring(sep1 + 1, sep2).toInt(); /* OpenHAB saturation (0-100%) */ int green = value.substring(sep1 + 1, sep2).toInt();
int blue = value.substring(sep2 + 1, value.length()).toInt(); /* brightness (0-100%) */ int blue = value.substring(sep2 + 1, value.length()).toInt();
uint8_t r = (red * 255) / 250; uint8_t r = (red * 255) / 250;
uint8_t g = (green *255) / 250; uint8_t g = (green *255) / 250;
@ -314,9 +320,10 @@ bool ledHandler(const HomieRange& range, const String& value) {
uint32_t c = strip.Color(r,g,b); uint32_t c = strip.Color(r,g,b);
strip.fill(c); strip.fill(c);
strip.show(); strip.show();
ledStripNode.setProperty(NODE_AMBIENT).send(String(r) + "," + String(g) + "," + String(b)); ledStripNode.setProperty(NODE_AMBIENT).send(value);
return true; return true;
} }
}
return false; return false;
} }