mirror of
https://github.com/Threnklyn/esphome-dev.git
synced 2026-05-26 07:38:30 +02:00
Tuya improvements (#1491)
Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com>
This commit is contained in:
@@ -9,17 +9,17 @@ static const char *TAG = "tuya.sensor";
|
||||
void TuyaSensor::setup() {
|
||||
this->parent_->register_listener(this->sensor_id_, [this](TuyaDatapoint datapoint) {
|
||||
if (datapoint.type == TuyaDatapointType::BOOLEAN) {
|
||||
ESP_LOGV(TAG, "MCU reported sensor %u is: %s", datapoint.id, ONOFF(datapoint.value_bool));
|
||||
this->publish_state(datapoint.value_bool);
|
||||
ESP_LOGD(TAG, "MCU reported sensor is: %s", ONOFF(datapoint.value_bool));
|
||||
} else if (datapoint.type == TuyaDatapointType::INTEGER) {
|
||||
ESP_LOGV(TAG, "MCU reported sensor %u is: %d", datapoint.id, datapoint.value_int);
|
||||
this->publish_state(datapoint.value_int);
|
||||
ESP_LOGD(TAG, "MCU reported sensor is: %d", datapoint.value_int);
|
||||
} else if (datapoint.type == TuyaDatapointType::ENUM) {
|
||||
ESP_LOGV(TAG, "MCU reported sensor %u is: %u", datapoint.id, datapoint.value_enum);
|
||||
this->publish_state(datapoint.value_enum);
|
||||
ESP_LOGD(TAG, "MCU reported sensor is: %d", datapoint.value_enum);
|
||||
} else if (datapoint.type == TuyaDatapointType::BITMASK) {
|
||||
ESP_LOGV(TAG, "MCU reported sensor %u is: %x", datapoint.id, datapoint.value_bitmask);
|
||||
this->publish_state(datapoint.value_bitmask);
|
||||
ESP_LOGD(TAG, "MCU reported sensor is: %x", datapoint.value_bitmask);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user