ESPHome  2022.8.0
gpio_binary_sensor.cpp
Go to the documentation of this file.
1 #include "gpio_binary_sensor.h"
2 #include "esphome/core/log.h"
3 
4 namespace esphome {
5 namespace gpio {
6 
7 static const char *const TAG = "gpio.binary_sensor";
8 
10  this->pin_->setup();
11  this->publish_initial_state(this->pin_->digital_read());
12 }
13 
15  LOG_BINARY_SENSOR("", "GPIO Binary Sensor", this);
16  LOG_PIN(" Pin: ", this->pin_);
17 }
18 
20 
22 
23 } // namespace gpio
24 } // namespace esphome
void publish_initial_state(bool state)
Publish the initial state, this will not make the callback manager send callbacks and is meant only f...
virtual void setup()=0
float get_setup_priority() const override
Hardware priority.
void loop() override
Check sensor.
void publish_state(bool state)
Publish a new state to the front-end.
virtual bool digital_read()=0
const float HARDWARE
For components that deal with hardware and are very important like GPIO switch.
Definition: component.cpp:17
void setup() override
Setup pin.
Definition: a4988.cpp:4