Fix saving light state for restore modes LIGHT_RESTORE_AND_OFF/ON (#4131)

This commit is contained in:
myhomeiot 2022-12-22 09:57:53 +02:00 committed by GitHub
parent 50e8e92f0b
commit 57a1c207c2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -276,7 +276,15 @@ void LightState::set_immediately_(const LightColorValues &target, bool set_remot
void LightState::save_remote_values_() {
LightStateRTCState saved;
saved.color_mode = this->remote_values.get_color_mode();
saved.state = this->remote_values.is_on();
switch (this->restore_mode_) {
case LIGHT_RESTORE_AND_OFF:
case LIGHT_RESTORE_AND_ON:
saved.state = (this->restore_mode_ == LIGHT_RESTORE_AND_ON);
break;
default:
saved.state = this->remote_values.is_on();
break;
}
saved.brightness = this->remote_values.get_brightness();
saved.color_brightness = this->remote_values.get_color_brightness();
saved.red = this->remote_values.get_red();