ESPHome 2026.6.0-dev
Loading...
Searching...
No Matches
gpio_switch.h
Go to the documentation of this file.
1#pragma once
2
4#include "esphome/core/hal.h"
7
8namespace esphome::gpio {
9
10class GPIOSwitch final : public switch_::Switch, public Component {
11 public:
12 void set_pin(GPIOPin *pin) { pin_ = pin; }
13
14 // ========== INTERNAL METHODS ==========
15 // (In most use cases you won't need these)
16 float get_setup_priority() const override;
17
18 void setup() override;
19 void dump_config() override;
20#ifdef USE_GPIO_SWITCH_INTERLOCK
21 void set_interlock(const std::initializer_list<Switch *> &interlock);
22 void set_interlock_wait_time(uint32_t interlock_wait_time) { interlock_wait_time_ = interlock_wait_time; }
23#endif
24
25 protected:
26 void write_state(bool state) override;
27
29#ifdef USE_GPIO_SWITCH_INTERLOCK
32#endif
33};
34
35} // namespace esphome::gpio
Fixed-capacity vector - allocates once at runtime, never reallocates This avoids std::vector template...
Definition helpers.h:529
void dump_config() override
float get_setup_priority() const override
void set_interlock(const std::initializer_list< Switch * > &interlock)
void set_interlock_wait_time(uint32_t interlock_wait_time)
Definition gpio_switch.h:22
void write_state(bool state) override
void set_pin(GPIOPin *pin)
Definition gpio_switch.h:12
FixedVector< Switch * > interlock_
Definition gpio_switch.h:30
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