ESPHome 2025.5.0
Loading...
Searching...
No Matches
tuya_binary_sensor.cpp
Go to the documentation of this file.
1#include "esphome/core/log.h"
3
4namespace esphome {
5namespace tuya {
6
7static const char *const TAG = "tuya.binary_sensor";
8
10 this->parent_->register_listener(this->sensor_id_, [this](const TuyaDatapoint &datapoint) {
11 ESP_LOGV(TAG, "MCU reported binary sensor %u is: %s", datapoint.id, ONOFF(datapoint.value_bool));
12 this->publish_state(datapoint.value_bool);
13 });
14}
15
17 ESP_LOGCONFIG(TAG, "Tuya Binary Sensor:");
18 ESP_LOGCONFIG(TAG, " Binary Sensor has datapoint ID %u", this->sensor_id_);
19}
20
21} // namespace tuya
22} // namespace esphome
void publish_state(bool 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:697
const char *const TAG
Definition spi.cpp:8
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7