ESPHome 2026.11.0-dev
Loading...
Searching...
No Matches
tca8418_binary_sensor.h
Go to the documentation of this file.
1#pragma once
2
4#include "../tca8418.h"
5
6namespace esphome::tca8418 {
7
10 public:
11 explicit TCA8418BinarySensor(uint8_t key) : key_(key) {}
12
13 void key_pressed(uint8_t key) override {
14 if (key == this->key_)
15 this->publish_state(true);
16 }
17 void key_released(uint8_t key) override {
18 if (key == this->key_)
19 this->publish_state(false);
20 }
21
22 protected:
23 const uint8_t key_;
24};
25
26} // namespace esphome::tca8418
void publish_state(bool new_state)
Publish a new state to the front-end.
One key of a TCA8418, matched by the key number codegen resolved from the config.