mirror of
https://github.com/esphome/esphome.git
synced 2025-02-27 15:28:29 +00: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
esphome/components
@ -10,7 +10,7 @@ float GPIOSwitch::get_setup_priority() const { return setup_priority::HARDWARE;
|
|||||||
void GPIOSwitch::setup() {
|
void GPIOSwitch::setup() {
|
||||||
ESP_LOGCONFIG(TAG, "Setting up GPIO Switch '%s'...", this->name_.c_str());
|
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
|
// write state before setup
|
||||||
if (initial_state) {
|
if (initial_state) {
|
||||||
|
@ -10,7 +10,7 @@ void OutputSwitch::dump_config() { LOG_SWITCH("", "Output Switch", this); }
|
|||||||
void OutputSwitch::setup() {
|
void OutputSwitch::setup() {
|
||||||
ESP_LOGCONFIG(TAG, "Setting up Output Switch '%s'...", this->name_.c_str());
|
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) {
|
if (initial_state) {
|
||||||
this->turn_on();
|
this->turn_on();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user