fix device_class #2980

This commit is contained in:
MichaelDvP
2026-03-15 14:12:47 +01:00
parent f1fc8d9aae
commit 69d4163b9d

View File

@@ -1191,7 +1191,11 @@ void Mqtt::add_ha_classes(JsonObject doc, const uint8_t device_type, const uint8
doc[ic_ha] = F_(iconpercent); // set icon
}
doc[sc_ha] = sc_ha_measurement;
doc[dc_ha] = "power_factor";
if (entity == FL_(airHumidity)[0] || entity == FL_(remotehum)[0]) {
doc[dc_ha] = "humidity";
} else if (entity == FL_(battery)[0]) {
doc[dc_ha] = "battery";
}
break;
case DeviceValueUOM::SECONDS:
case DeviceValueUOM::MINUTES:
@@ -1544,8 +1548,8 @@ void Mqtt::add_ha_dev_section(JsonObject doc, const char * name, const bool crea
}
// add mf (manufacturer/brand), mdl (model), sw (software version) and via_device
dev_json["mf"] = brand != nullptr ? brand : "EMS-ESP";
dev_json["mdl"] = model != nullptr ? model : "EMS-ESP";
dev_json["mf"] = brand != nullptr ? brand : "EMS-ESP";
dev_json["mdl"] = model != nullptr ? model : "EMS-ESP";
dev_json["sw"] = version != nullptr ? version : "v" + std::string(EMSESP_APP_VERSION);
dev_json["via_device"] = Mqtt::basename();
}