Fixed publish_current_state()
This commit is contained in:
@@ -106,12 +106,30 @@ void State::publish_current_state() {
|
||||
StaticJsonDocument<512> json;
|
||||
json["state"] = (mode==AM_OFF) ? "OFF" : "ON";
|
||||
json["brightness"] = FastLED.getBrightness();
|
||||
json["effect"] = mode;
|
||||
json["effect"] = animation_mode_names[get_active_mode()];
|
||||
JsonObject rgb = json.createNestedObject("rgb");
|
||||
rgb["r"] = color.r;
|
||||
rgb["g"] = color.g;
|
||||
rgb["b"] = color.b;
|
||||
String result = "";
|
||||
serializeJson(json, result);
|
||||
LOGln("Reporting current state: %s", result.c_str());
|
||||
mqtt_publish_current_state(result);
|
||||
}
|
||||
|
||||
AnimationMode State::get_active_mode() {
|
||||
AnimationMode active_mode = mode;
|
||||
if (temp_mode_until > 0) {
|
||||
if (temp_mode_until>millis()) {
|
||||
active_mode = temp_mode;
|
||||
} else {
|
||||
temp_mode_until = 0;
|
||||
if (return_to_brightness != -1) {
|
||||
FastLED.setBrightness(return_to_brightness);
|
||||
return_to_brightness = -1;
|
||||
}
|
||||
State::publish_current_state();
|
||||
}
|
||||
}
|
||||
return active_mode;
|
||||
}
|
Reference in New Issue
Block a user