fix HA mapping for uA and l/min

This commit is contained in:
proddy
2025-12-27 17:33:46 +01:00
parent d22a369333
commit 11bef52568

View File

@@ -1145,7 +1145,7 @@ void Mqtt::add_ha_classes(JsonObject doc, const uint8_t device_type, const uint8
const char * sc_ha_total_increasing = "total_increasing"; const char * sc_ha_total_increasing = "total_increasing";
// set uom, unless boolean - as HA is fussy with the naming // set uom, unless boolean - as HA is fussy with the naming
// using HA uom specific codes from https://github.com/home-assistant/core/blob/dev/homeassistant/const.py // map too HA uom specific codes from https://github.com/home-assistant/core/blob/dev/homeassistant/const.py
if (type != DeviceValueType::BOOL) { if (type != DeviceValueType::BOOL) {
if (uom == DeviceValueUOM::HOURS) { if (uom == DeviceValueUOM::HOURS) {
doc[uom_ha] = "h"; doc[uom_ha] = "h";
@@ -1155,6 +1155,8 @@ void Mqtt::add_ha_classes(JsonObject doc, const uint8_t device_type, const uint8
doc[uom_ha] = "s"; doc[uom_ha] = "s";
} else if (uom == DeviceValueUOM::KB) { } else if (uom == DeviceValueUOM::KB) {
doc[uom_ha] = "kB"; doc[uom_ha] = "kB";
} else if (uom == DeviceValueUOM::LMIN) {
doc[uom_ha] = "L/min";
} else if (uom != DeviceValueUOM::NONE) { } else if (uom != DeviceValueUOM::NONE) {
doc[uom_ha] = EMSdevice::uom_to_string(uom); // use default doc[uom_ha] = EMSdevice::uom_to_string(uom); // use default
} else if (discovery_type() != discoveryType::HOMEASSISTANT) { } else if (discovery_type() != discoveryType::HOMEASSISTANT) {
@@ -1225,7 +1227,7 @@ void Mqtt::add_ha_classes(JsonObject doc, const uint8_t device_type, const uint8
doc[ic_ha] = F_(iconua); doc[ic_ha] = F_(iconua);
} }
doc[sc_ha] = sc_ha_measurement; doc[sc_ha] = sc_ha_measurement;
doc[dc_ha] = "current"; // doc[dc_ha] = "current"; // there is no uA in HA, only mA
break; break;
case DeviceValueUOM::BAR: case DeviceValueUOM::BAR:
doc[sc_ha] = sc_ha_measurement; doc[sc_ha] = sc_ha_measurement;