diff --git a/esphome/components/gpio/switch/gpio_switch.cpp b/esphome/components/gpio/switch/gpio_switch.cpp index 3085fa33dc..5033315b5e 100644 --- a/esphome/components/gpio/switch/gpio_switch.cpp +++ b/esphome/components/gpio/switch/gpio_switch.cpp @@ -10,7 +10,7 @@ float GPIOSwitch::get_setup_priority() const { return setup_priority::HARDWARE; void GPIOSwitch::setup() { ESP_LOGCONFIG(TAG, "Setting up GPIO Switch '%s'...", this->name_.c_str()); - bool initial_state = Switch::get_initial_state_with_restore_mode(); + bool initial_state = this->get_initial_state_with_restore_mode().value_or(false); // write state before setup if (initial_state) { diff --git a/esphome/components/output/switch/output_switch.cpp b/esphome/components/output/switch/output_switch.cpp index 7254451370..0e045d18b4 100644 --- a/esphome/components/output/switch/output_switch.cpp +++ b/esphome/components/output/switch/output_switch.cpp @@ -10,7 +10,7 @@ void OutputSwitch::dump_config() { LOG_SWITCH("", "Output Switch", this); } void OutputSwitch::setup() { ESP_LOGCONFIG(TAG, "Setting up Output Switch '%s'...", this->name_.c_str()); - bool initial_state = Switch::get_initial_state_with_restore_mode(); + bool initial_state = this->get_initial_state_with_restore_mode().value_or(false); if (initial_state) { this->turn_on();