Handle enum type in tuya text_sensor (#5626)

This commit is contained in:
Jesse Hills 2023-10-30 11:00:47 +13:00 committed by GitHub
parent f36ec7c726
commit 0c46403eaf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,5 +1,5 @@
#include "esphome/core/log.h"
#include "tuya_text_sensor.h"
#include "esphome/core/log.h"
namespace esphome {
namespace tuya {
@ -19,6 +19,12 @@ void TuyaTextSensor::setup() {
this->publish_state(data);
break;
}
case TuyaDatapointType::ENUM: {
std::string data = to_string(datapoint.value_enum);
ESP_LOGD(TAG, "MCU reported text sensor %u is: %s", datapoint.id, data.c_str());
this->publish_state(data);
break;
}
default:
ESP_LOGW(TAG, "Unsupported data type for tuya text sensor %u: %#02hhX", datapoint.id, (uint8_t) datapoint.type);
break;