fix switch initialization (#4153)

Co-authored-by: Samuel Sieb <samuel@sieb.net>
fixes https://github.com/esphome/issues/issues/3878
This commit is contained in:
Samuel Sieb 2022-12-06 02:25:19 -08:00 committed by GitHub
parent 48da5ef1c4
commit 30a2fc1273
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 2 deletions

View file

@ -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) {

View file

@ -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();