mirror of
https://github.com/esphome/esphome.git
synced 2025-10-29 06:04:01 +00:00
Change color model to fix white channel issues (#1895)
This commit is contained in:
@@ -378,6 +378,7 @@ message LightStateResponse {
|
||||
fixed32 key = 1;
|
||||
bool state = 2;
|
||||
float brightness = 3;
|
||||
float color_brightness = 10;
|
||||
float red = 4;
|
||||
float green = 5;
|
||||
float blue = 6;
|
||||
@@ -396,6 +397,8 @@ message LightCommandRequest {
|
||||
bool state = 3;
|
||||
bool has_brightness = 4;
|
||||
float brightness = 5;
|
||||
bool has_color_brightness = 20;
|
||||
float color_brightness = 21;
|
||||
bool has_rgb = 6;
|
||||
float red = 7;
|
||||
float green = 8;
|
||||
|
||||
@@ -308,6 +308,7 @@ bool APIConnection::send_light_state(light::LightState *light) {
|
||||
if (traits.get_supports_brightness())
|
||||
resp.brightness = values.get_brightness();
|
||||
if (traits.get_supports_rgb()) {
|
||||
resp.color_brightness = values.get_color_brightness();
|
||||
resp.red = values.get_red();
|
||||
resp.green = values.get_green();
|
||||
resp.blue = values.get_blue();
|
||||
@@ -352,6 +353,8 @@ void APIConnection::light_command(const LightCommandRequest &msg) {
|
||||
call.set_state(msg.state);
|
||||
if (msg.has_brightness)
|
||||
call.set_brightness(msg.brightness);
|
||||
if (msg.has_color_brightness)
|
||||
call.set_color_brightness(msg.color_brightness);
|
||||
if (msg.has_rgb) {
|
||||
call.set_red(msg.red);
|
||||
call.set_green(msg.green);
|
||||
|
||||
@@ -1263,6 +1263,10 @@ bool LightStateResponse::decode_32bit(uint32_t field_id, Proto32Bit value) {
|
||||
this->brightness = value.as_float();
|
||||
return true;
|
||||
}
|
||||
case 10: {
|
||||
this->color_brightness = value.as_float();
|
||||
return true;
|
||||
}
|
||||
case 4: {
|
||||
this->red = value.as_float();
|
||||
return true;
|
||||
@@ -1291,6 +1295,7 @@ void LightStateResponse::encode(ProtoWriteBuffer buffer) const {
|
||||
buffer.encode_fixed32(1, this->key);
|
||||
buffer.encode_bool(2, this->state);
|
||||
buffer.encode_float(3, this->brightness);
|
||||
buffer.encode_float(10, this->color_brightness);
|
||||
buffer.encode_float(4, this->red);
|
||||
buffer.encode_float(5, this->green);
|
||||
buffer.encode_float(6, this->blue);
|
||||
@@ -1315,6 +1320,11 @@ void LightStateResponse::dump_to(std::string &out) const {
|
||||
out.append(buffer);
|
||||
out.append("\n");
|
||||
|
||||
out.append(" color_brightness: ");
|
||||
sprintf(buffer, "%g", this->color_brightness);
|
||||
out.append(buffer);
|
||||
out.append("\n");
|
||||
|
||||
out.append(" red: ");
|
||||
sprintf(buffer, "%g", this->red);
|
||||
out.append(buffer);
|
||||
@@ -1359,6 +1369,10 @@ bool LightCommandRequest::decode_varint(uint32_t field_id, ProtoVarInt value) {
|
||||
this->has_brightness = value.as_bool();
|
||||
return true;
|
||||
}
|
||||
case 20: {
|
||||
this->has_color_brightness = value.as_bool();
|
||||
return true;
|
||||
}
|
||||
case 6: {
|
||||
this->has_rgb = value.as_bool();
|
||||
return true;
|
||||
@@ -1415,6 +1429,10 @@ bool LightCommandRequest::decode_32bit(uint32_t field_id, Proto32Bit value) {
|
||||
this->brightness = value.as_float();
|
||||
return true;
|
||||
}
|
||||
case 21: {
|
||||
this->color_brightness = value.as_float();
|
||||
return true;
|
||||
}
|
||||
case 7: {
|
||||
this->red = value.as_float();
|
||||
return true;
|
||||
@@ -1445,6 +1463,8 @@ void LightCommandRequest::encode(ProtoWriteBuffer buffer) const {
|
||||
buffer.encode_bool(3, this->state);
|
||||
buffer.encode_bool(4, this->has_brightness);
|
||||
buffer.encode_float(5, this->brightness);
|
||||
buffer.encode_bool(20, this->has_color_brightness);
|
||||
buffer.encode_float(21, this->color_brightness);
|
||||
buffer.encode_bool(6, this->has_rgb);
|
||||
buffer.encode_float(7, this->red);
|
||||
buffer.encode_float(8, this->green);
|
||||
@@ -1485,6 +1505,15 @@ void LightCommandRequest::dump_to(std::string &out) const {
|
||||
out.append(buffer);
|
||||
out.append("\n");
|
||||
|
||||
out.append(" has_color_brightness: ");
|
||||
out.append(YESNO(this->has_color_brightness));
|
||||
out.append("\n");
|
||||
|
||||
out.append(" color_brightness: ");
|
||||
sprintf(buffer, "%g", this->color_brightness);
|
||||
out.append(buffer);
|
||||
out.append("\n");
|
||||
|
||||
out.append(" has_rgb: ");
|
||||
out.append(YESNO(this->has_rgb));
|
||||
out.append("\n");
|
||||
|
||||
@@ -371,6 +371,7 @@ class LightStateResponse : public ProtoMessage {
|
||||
uint32_t key{0};
|
||||
bool state{false};
|
||||
float brightness{0.0f};
|
||||
float color_brightness{0.0f};
|
||||
float red{0.0f};
|
||||
float green{0.0f};
|
||||
float blue{0.0f};
|
||||
@@ -392,6 +393,8 @@ class LightCommandRequest : public ProtoMessage {
|
||||
bool state{false};
|
||||
bool has_brightness{false};
|
||||
float brightness{0.0f};
|
||||
bool has_color_brightness{false};
|
||||
float color_brightness{0.0f};
|
||||
bool has_rgb{false};
|
||||
float red{0.0f};
|
||||
float green{0.0f};
|
||||
|
||||
Reference in New Issue
Block a user