ESPHome 2025.5.0
Loading...
Searching...
No Matches
automation.cpp
Go to the documentation of this file.
1#include "esphome/core/log.h"
2
3#include "automation.h"
4
5static const char *const TAG = "tuya.automation";
6
7namespace esphome {
8namespace tuya {
9
11 if (dp.type != expected) {
12 ESP_LOGW(TAG, "Tuya sensor %u expected datapoint type %#02hhX but got %#02hhX", dp.id,
13 static_cast<uint8_t>(expected), static_cast<uint8_t>(dp.type));
14 }
15}
16
18 parent->register_listener(sensor_id, [this](const TuyaDatapoint &dp) {
20 this->trigger(dp.value_raw);
21 });
22}
23
25 parent->register_listener(sensor_id, [this](const TuyaDatapoint &dp) {
27 this->trigger(dp.value_bool);
28 });
29}
30
32 parent->register_listener(sensor_id, [this](const TuyaDatapoint &dp) {
34 this->trigger(dp.value_int);
35 });
36}
37
39 parent->register_listener(sensor_id, [this](const TuyaDatapoint &dp) {
41 this->trigger(dp.value_uint);
42 });
43}
44
46 parent->register_listener(sensor_id, [this](const TuyaDatapoint &dp) {
48 this->trigger(dp.value_string);
49 });
50}
51
53 parent->register_listener(sensor_id, [this](const TuyaDatapoint &dp) {
55 this->trigger(dp.value_enum);
56 });
57}
58
65
66} // namespace tuya
67} // namespace esphome
TuyaBitmaskDatapointUpdateTrigger(Tuya *parent, uint8_t sensor_id)
TuyaBoolDatapointUpdateTrigger(Tuya *parent, uint8_t sensor_id)
TuyaEnumDatapointUpdateTrigger(Tuya *parent, uint8_t sensor_id)
void register_listener(uint8_t datapoint_id, const std::function< void(TuyaDatapoint)> &func)
Definition tuya.cpp:697
TuyaIntDatapointUpdateTrigger(Tuya *parent, uint8_t sensor_id)
TuyaRawDatapointUpdateTrigger(Tuya *parent, uint8_t sensor_id)
TuyaStringDatapointUpdateTrigger(Tuya *parent, uint8_t sensor_id)
TuyaUIntDatapointUpdateTrigger(Tuya *parent, uint8_t sensor_id)
const char *const TAG
Definition spi.cpp:8
void check_expected_datapoint(const TuyaDatapoint &dp, TuyaDatapointType expected)
TuyaDatapointType
Definition tuya.h:19
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7
std::string value_string
Definition tuya.h:39
std::vector< uint8_t > value_raw
Definition tuya.h:40
TuyaDatapointType type
Definition tuya.h:30