1
0
mirror of https://github.com/esphome/esphome.git synced 2025-04-12 22:00:30 +01:00

Initialise h-bridge switch to requested initial state (#8363)

This commit is contained in:
Chris Djali 2025-03-07 00:43:04 +00:00 committed by GitHub
parent 83cba0d7bd
commit 3e9556c6c2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -12,7 +12,7 @@ float HBridgeSwitch::get_setup_priority() const { return setup_priority::HARDWAR
void HBridgeSwitch::setup() {
ESP_LOGCONFIG(TAG, "Setting up H-Bridge Switch '%s'...", this->name_.c_str());
optional<bool> initial_state = this->get_initial_state_with_restore_mode().value_or(false);
optional<bool> initial_state = this->get_initial_state_with_restore_mode();
// Like GPIOSwitch does, set the pin state both before and after pin setup()
this->on_pin_->digital_write(false);
@ -24,7 +24,7 @@ void HBridgeSwitch::setup() {
this->off_pin_->digital_write(false);
if (initial_state.has_value())
this->write_state(initial_state);
this->write_state(initial_state.value());
}
void HBridgeSwitch::dump_config() {