ESPHome 2026.5.1
Loading...
Searching...
No Matches
tuya_binary_sensor.cpp
Go to the documentation of this file.
1#include "esphome/core/log.h"
3
4namespace esphome::tuya {
5
6static const char *const TAG = "tuya.binary_sensor";
7
9 this->parent_->register_listener(this->sensor_id_, [this](const TuyaDatapoint &datapoint) {
10 ESP_LOGV(TAG, "MCU reported binary sensor %u is: %s", datapoint.id, ONOFF(datapoint.value_bool));
11 this->publish_state(datapoint.value_bool);
12 });
13}
14
16 ESP_LOGCONFIG(TAG,
17 "Tuya Binary Sensor:\n"
18 " Binary Sensor has datapoint ID %u",
19 this->sensor_id_);
20}
21
22} // namespace esphome::tuya
void publish_state(bool new_state)
Publish a new state to the front-end.
void register_listener(uint8_t datapoint_id, const std::function< void(TuyaDatapoint)> &func)
Definition tuya.cpp:749
const char *const TAG
Definition spi.cpp:7