Handle enum type in tuya text_sensor (#5626)

This commit is contained in:
Jesse Hills 2023-10-30 11:00:47 +13:00
parent f96a839bcf
commit a1845e1e72
No known key found for this signature in database
GPG key ID: BEAAE804EFD8E83A

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;