7static const char *
const TAG =
"gpio.binary_sensor";
9#if ESPHOME_LOG_LEVEL >= ESPHOME_LOG_LEVEL_DEBUG
13 return LOG_STR(
"RISING_EDGE");
15 return LOG_STR(
"FALLING_EDGE");
17 return LOG_STR(
"ANY_EDGE");
19 return LOG_STR(
"UNKNOWN");
23static const LogString *gpio_mode_to_string(
bool use_interrupt) {
24 return use_interrupt ? LOG_STR(
"interrupt") : LOG_STR(
"polling");
56 ESP_LOGD(TAG,
"GPIO is not internal, falling back to polling mode");
71 LOG_BINARY_SENSOR(
"",
"GPIO Binary Sensor",
this);
72 LOG_PIN(
" Pin: ", this->
pin_);
73 ESP_LOGCONFIG(TAG,
" Mode: %s", LOG_STR_ARG(gpio_mode_to_string(this->
use_interrupt_)));
75 ESP_LOGCONFIG(TAG,
" Interrupt Type: %s", LOG_STR_ARG(interrupt_type_to_string(this->
interrupt_type_)));
void enable_loop_soon_any_context()
Thread and ISR-safe version of enable_loop() that can be called from any context.
void disable_loop()
Disable this component's loop.
virtual bool is_internal()
virtual bool digital_read()=0
void attach_interrupt(void(*func)(T *), T *arg, gpio::InterruptType type) const
virtual ISRInternalGPIOPin to_isr() const =0
void publish_state(bool new_state)
Publish a new state to the front-end.
void publish_initial_state(bool new_state)
Publish the initial state, this will not make the callback manager send callbacks and is meant only f...
void dump_config() override
void loop() override
Check sensor.
gpio::InterruptType interrupt_type_
float get_setup_priority() const override
Hardware priority.
GPIOBinarySensorStore store_
void setup() override
Setup pin.
ISRInternalGPIOPin isr_pin_
void setup(InternalGPIOPin *pin, gpio::InterruptType type, Component *component)
volatile bool last_state_
static void gpio_intr(GPIOBinarySensorStore *arg)
const float HARDWARE
For components that deal with hardware and are very important like GPIO switch.
Providing packet encoding functions for exchanging data with a remote host.