ESPHome 2026.6.0-dev
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::tuya {
8
10 if (dp.type != expected) {
11 ESP_LOGW(TAG, "Tuya sensor %u expected datapoint type %#02hhX but got %#02hhX", dp.id,
12 static_cast<uint8_t>(expected), static_cast<uint8_t>(dp.type));
13 }
14}
15
17 parent->register_listener(sensor_id, [this](const TuyaDatapoint &dp) {
19 this->trigger(dp.value_raw);
20 });
21}
22
24 parent->register_listener(sensor_id, [this](const TuyaDatapoint &dp) {
26 this->trigger(dp.value_bool);
27 });
28}
29
31 parent->register_listener(sensor_id, [this](const TuyaDatapoint &dp) {
33 this->trigger(dp.value_int);
34 });
35}
36
38 parent->register_listener(sensor_id, [this](const TuyaDatapoint &dp) {
40 this->trigger(dp.value_uint);
41 });
42}
43
45 parent->register_listener(sensor_id, [this](const TuyaDatapoint &dp) {
47 this->trigger(dp.value_string);
48 });
49}
50
52 parent->register_listener(sensor_id, [this](const TuyaDatapoint &dp) {
54 this->trigger(dp.value_enum);
55 });
56}
57
64
65} // namespace esphome::tuya
void trigger(const Ts &...x) ESPHOME_ALWAYS_INLINE
Definition automation.h:461
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:749
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:7
void check_expected_datapoint(const TuyaDatapoint &dp, TuyaDatapointType expected)
Definition automation.cpp:9
TuyaDatapointType
Definition tuya.h:18
std::string value_string
Definition tuya.h:38
std::vector< uint8_t > value_raw
Definition tuya.h:39
TuyaDatapointType type
Definition tuya.h:29