From 69d4163b9d6d1375c43f670019484943097d51de Mon Sep 17 00:00:00 2001 From: MichaelDvP Date: Sun, 15 Mar 2026 14:12:47 +0100 Subject: [PATCH] fix device_class #2980 --- src/core/mqtt.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/core/mqtt.cpp b/src/core/mqtt.cpp index 225c7f56e..b73f4ef25 100644 --- a/src/core/mqtt.cpp +++ b/src/core/mqtt.cpp @@ -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(); }