From 57a1c207c2df36015a970629b45fbbb1a9146476 Mon Sep 17 00:00:00 2001 From: myhomeiot <70070601+myhomeiot@users.noreply.github.com> Date: Thu, 22 Dec 2022 09:57:53 +0200 Subject: [PATCH] Fix saving light state for restore modes LIGHT_RESTORE_AND_OFF/ON (#4131) --- esphome/components/light/light_state.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/esphome/components/light/light_state.cpp b/esphome/components/light/light_state.cpp index 00c03eb5f0..64c29a346b 100644 --- a/esphome/components/light/light_state.cpp +++ b/esphome/components/light/light_state.cpp @@ -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();