Save and restore color values
This commit is contained in:
@@ -18,7 +18,6 @@ void AppStatus::loop() {
|
||||
}
|
||||
|
||||
this->publish_status_(status);
|
||||
this->last_status_ = status;
|
||||
}
|
||||
|
||||
void AppStatus::dump_config() {
|
||||
@@ -40,6 +39,24 @@ void AppStatus::publish_status_(uint8_t status) {
|
||||
if (this->include_warnings_ && (status & STATUS_LED_WARNING)) {
|
||||
result = true;
|
||||
}
|
||||
if (this->light_ != nullptr) {
|
||||
if (this->last_status_ == 0 && status != 0) {
|
||||
this->saved_light_values_ = this->light_->current_values;
|
||||
auto call = this->light_->turn_on();
|
||||
call.set_brightness(0.30);
|
||||
call.set_rgb(1.0, 0.0, 1.0);
|
||||
call.set_transition_length(0);
|
||||
call.set_publish(false);
|
||||
call.perform();
|
||||
} else if (this->last_status_ != 0 && status == 0) {
|
||||
auto call = this->light_->make_call();
|
||||
call.from_light_color_values(this->saved_light_values_);
|
||||
call.set_transition_length(0);
|
||||
call.set_publish(false);
|
||||
call.perform();
|
||||
}
|
||||
}
|
||||
this->last_status_ = status;
|
||||
this->publish_state(result);
|
||||
}
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ class AppStatus : public binary_sensor::BinarySensor, public Component {
|
||||
bool include_warnings_{true};
|
||||
bool include_errors_{true};
|
||||
light::LightState *light_{nullptr};
|
||||
light::LightColorValues saved_light_values_;
|
||||
|
||||
uint8_t get_status_() const;
|
||||
void publish_status_(uint8_t status);
|
||||
|
||||
Reference in New Issue
Block a user