ESPHome 2026.11.0b6
Loading...
Searching...
No Matches
gpio_binary_output.h
Go to the documentation of this file.
1#pragma once
2
4#include "esphome/core/hal.h"
6
7namespace esphome::gpio {
8
9class GPIOBinaryOutput final : public output::BinaryOutput, public Component {
10 public:
11 void set_pin(GPIOPin *pin) { pin_ = pin; }
12
13 void setup() override {
14 const bool held = this->pin_->is_held();
15 if (!held)
16 this->turn_off();
17 this->pin_->setup();
18 if (!held)
19 this->turn_off();
20 }
21 void dump_config() override;
22 float get_setup_priority() const override { return setup_priority::HARDWARE; }
23
24 protected:
25 void write_state(bool state) override { this->pin_->digital_write(state); }
26
28};
29
30} // namespace esphome::gpio
virtual void setup()=0
virtual void digital_write(bool value)=0
virtual bool is_held() const
Definition gpio_pin.h:90
float get_setup_priority() const override
void write_state(bool state) override
virtual void turn_off()
Disable this binary output.
bool state
Definition fan.h:2
constexpr float HARDWARE
For components that deal with hardware and are very important like GPIO switch.
Definition component.h:43