From 3e9556c6c2ae734f826c4d9e971b4e2cb1bb95c5 Mon Sep 17 00:00:00 2001 From: Chris Djali Date: Fri, 7 Mar 2025 00:43:04 +0000 Subject: [PATCH] Initialise h-bridge switch to requested initial state (#8363) --- esphome/components/hbridge/switch/hbridge_switch.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/esphome/components/hbridge/switch/hbridge_switch.cpp b/esphome/components/hbridge/switch/hbridge_switch.cpp index 12d1c01bca..c0949be947 100644 --- a/esphome/components/hbridge/switch/hbridge_switch.cpp +++ b/esphome/components/hbridge/switch/hbridge_switch.cpp @@ -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 initial_state = this->get_initial_state_with_restore_mode().value_or(false); + optional 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() {