ESPHome  2024.12.2
tt21100_button.cpp
Go to the documentation of this file.
1 #include "tt21100_button.h"
2 #include "esphome/core/log.h"
3 
4 namespace esphome {
5 namespace tt21100 {
6 
7 static const char *const TAG = "tt21100.binary_sensor";
8 
10  this->parent_->register_button_listener(this);
11  this->publish_initial_state(false);
12 }
13 
15  LOG_BINARY_SENSOR("", "TT21100 Button", this);
16  ESP_LOGCONFIG(TAG, " Index: %u", this->index_);
17 }
18 
19 void TT21100Button::update_button(uint8_t index, uint16_t state) {
20  if (index != this->index_)
21  return;
22 
23  this->publish_state(state > 0);
24 }
25 
26 } // namespace tt21100
27 } // 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...
void update_button(uint8_t index, uint16_t state) override
bool state
The current reported state of the binary sensor.
Definition: binary_sensor.h:61
void publish_state(bool state)
Publish a new state to the front-end.
Implementation of SPI Controller mode.
Definition: a01nyub.cpp:7