1
0
mirror of https://github.com/esphome/esphome.git synced 2025-10-31 23:21:54 +00:00

make sure no dangling

This commit is contained in:
J. Nick Koston
2025-10-28 23:01:28 -05:00
parent e4aec7f413
commit b635689c29

View File

@@ -191,14 +191,15 @@ void Fan::save_state_() {
return;
}
auto traits = this->get_traits();
FanRestoreState state{};
state.state = this->state;
state.oscillating = this->oscillating;
state.speed = this->speed;
state.direction = this->direction;
if (this->get_traits().supports_preset_modes() && !this->preset_mode.empty()) {
auto traits = this->get_traits();
if (traits.supports_preset_modes() && !this->preset_mode.empty()) {
const auto &preset_modes = traits.supported_preset_modes();
// Store index of current preset mode
size_t i = 0;