mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-26 04:06:34 +00:00
Added Individual HSBCOLOR Commands for HomeKit
Added individual HSBCOLOR commands for better integration to HomeKit and OpenHab. Usage: HSBCOLOR1 <x> to set Hue HSBCOLOR2 <x> to set Saturation HSBCOLOR3 <x> to set Brightness Still is supported previous command HSBCOLOR <hue>,<sat>,<bri>
This commit is contained in:
parent
23155aa15e
commit
aa79874013
@ -1087,16 +1087,34 @@ boolean LightCommand()
|
|||||||
uint16_t HSB[3];
|
uint16_t HSB[3];
|
||||||
bool validHSB = true;
|
bool validHSB = true;
|
||||||
|
|
||||||
for (int i = 0; i < 3; i++) {
|
if (strstr(XdrvMailbox.data, ",")) { // Command with 3 comma separated parameters (Hue, Saturation AND Brightness)
|
||||||
char *substr;
|
for (int i = 0; i < 3; i++) {
|
||||||
|
char *substr;
|
||||||
|
|
||||||
if (0 == i) {
|
if (0 == i) {
|
||||||
substr = strtok(XdrvMailbox.data, ",");
|
substr = strtok(XdrvMailbox.data, ",");
|
||||||
} else {
|
} else {
|
||||||
substr = strtok(NULL, ",");
|
substr = strtok(NULL, ",");
|
||||||
|
}
|
||||||
|
if (substr != NULL) {
|
||||||
|
HSB[i] = atoi(substr);
|
||||||
|
} else {
|
||||||
|
validHSB = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (substr != NULL) {
|
} else { // Command with only 1 parameter (Hue, Saturation OR Brightness)
|
||||||
HSB[i] = atoi(substr);
|
float hsb[3];
|
||||||
|
|
||||||
|
LightGetHsb(&hsb[0],&hsb[1],&hsb[2]);
|
||||||
|
HSB[0] = round(hsb[0] * 360);
|
||||||
|
HSB[1] = round(hsb[1] * 100);
|
||||||
|
HSB[2] = round(hsb[2] * 100);
|
||||||
|
if (XdrvMailbox.index = 1) { // Hue
|
||||||
|
HSB[0] = XdrvMailbox.payload;
|
||||||
|
} else if (XdrvMailbox.index = 2) { // Saturation
|
||||||
|
HSB[1] = XdrvMailbox.payload;
|
||||||
|
} else if (XdrvMailbox.index = 3) { // Brightness
|
||||||
|
HSB[2] = XdrvMailbox.payload;
|
||||||
} else {
|
} else {
|
||||||
validHSB = false;
|
validHSB = false;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user