mirror of
https://github.com/esphome/esphome.git
synced 2024-11-10 01:07:45 +01:00
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:
parent
48da5ef1c4
commit
30a2fc1273
2 changed files with 2 additions and 2 deletions
|
@ -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) {
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Reference in a new issue