ESPHome 2026.6.0-dev
Loading...
Searching...
No Matches
hbridge_switch.h
Go to the documentation of this file.
1#pragma once
2
4#include "esphome/core/hal.h"
6
7#include <vector>
8
9namespace esphome::hbridge {
10
18
19class HBridgeSwitch : public switch_::Switch, public Component {
20 public:
21 void set_on_pin(GPIOPin *pin) { this->on_pin_ = pin; }
22 void set_off_pin(GPIOPin *pin) { this->off_pin_ = pin; }
23 void set_pulse_length(uint32_t pulse_length) { this->pulse_length_ = pulse_length; }
24 void set_wait_time(uint32_t wait_time) { this->wait_time_ = wait_time; }
25 void set_optimistic(bool optimistic) { this->optimistic_ = optimistic; }
26
27 // ========== INTERNAL METHODS ==========
28 // (In most use cases you won't need these)
29 float get_setup_priority() const override;
30
31 void setup() override;
32 void dump_config() override;
33
34 protected:
35 void write_state(bool state) override;
36 void timer_fn_();
37
38 bool timer_running_{false};
39 bool desired_state_{false};
41 GPIOPin *on_pin_{nullptr};
42 GPIOPin *off_pin_{nullptr};
45 bool optimistic_{false};
46};
47
48} // namespace esphome::hbridge
void write_state(bool state) override
void set_pulse_length(uint32_t pulse_length)
void set_optimistic(bool optimistic)
void set_wait_time(uint32_t wait_time)
float get_setup_priority() const override
Base class for all switches.
Definition switch.h:38
bool state
The current reported state of the binary sensor.
Definition switch.h:55
static void uint32_t