8static const char *
const TAG =
"gpio.binary_sensor";
10#if ESPHOME_LOG_LEVEL >= ESPHOME_LOG_LEVEL_DEBUG
16 return InterruptTypeStrings::get_log_str(
static_cast<uint8_t
>(
type), 0);
19static const LogString *gpio_mode_to_string(
bool use_interrupt) {
20 return use_interrupt ? LOG_STR(
"interrupt") : LOG_STR(
"polling");
52 ESP_LOGD(TAG,
"GPIO is not internal, falling back to polling mode");
67 LOG_BINARY_SENSOR(
"",
"GPIO Binary Sensor",
this);
68 LOG_PIN(
" Pin: ", this->
pin_);
69 ESP_LOGCONFIG(TAG,
" Mode: %s", LOG_STR_ARG(gpio_mode_to_string(this->
use_interrupt_)));
71 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 ESPDEPRECATED("Override dump_summary(char*, size_t) instead. Will be removed in 2026.7.0.", "2026.1.0") virtual std boo is_internal)()
Get a summary of this pin as a string.
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 Component * component
PROGMEM_STRING_TABLE(InterruptTypeStrings, "UNKNOWN", "RISING_EDGE", "FALLING_EDGE", "ANY_EDGE")
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.