7 static const char *
const TAG =
"tuya.text_sensor";
11 switch (datapoint.
type) {
12 case TuyaDatapointType::STRING:
13 ESP_LOGD(TAG,
"MCU reported text sensor %u is: %s", datapoint.id, datapoint.value_string.c_str());
14 this->publish_state(datapoint.value_string);
16 case TuyaDatapointType::RAW: {
17 std::string data = format_hex_pretty(datapoint.value_raw);
18 ESP_LOGD(TAG,
"MCU reported text sensor %u is: %s", datapoint.id, data.c_str());
19 this->publish_state(data);
23 std::string data = to_string(datapoint.value_enum);
24 ESP_LOGD(TAG,
"MCU reported text sensor %u is: %s", datapoint.id, data.c_str());
25 this->publish_state(data);
29 ESP_LOGW(TAG,
"Unsupported data type for tuya text sensor %u: %#02hhX", datapoint.
id, (uint8_t) datapoint.
type);
36 ESP_LOGCONFIG(TAG,
"Tuya Text Sensor:");
37 ESP_LOGCONFIG(TAG,
" Text Sensor has datapoint ID %u", this->
sensor_id_);
void dump_config() override
void register_listener(uint8_t datapoint_id, const std::function< void(TuyaDatapoint)> &func)
Implementation of SPI Controller mode.