Tuya improvements (#1491)

Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com>
This commit is contained in:
Trevor North
2021-06-02 10:31:56 +01:00
committed by GitHub
parent c3938d04f3
commit c5c24c1989
12 changed files with 321 additions and 219 deletions
@@ -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);
}
});
}