Merge pull request #2985 from MichaelDvP/dev

devcie class #2980 and version update #2981, dev10
This commit is contained in:
Proddy
2026-03-17 20:17:29 +01:00
committed by GitHub
5 changed files with 22 additions and 5 deletions

View File

@@ -25,3 +25,5 @@ For more details go to [emsesp.org](https://emsesp.org/).
- store scheduler active state to nvs [#2946](https://github.com/emsesp/EMS-ESP32/discussions/2946) - store scheduler active state to nvs [#2946](https://github.com/emsesp/EMS-ESP32/discussions/2946)
- translated modes `heat` and `eco` for HA-climate mode-str-tpl - translated modes `heat` and `eco` for HA-climate mode-str-tpl
- support `minflowtemp` and `baseflowtemp` [#2969](https://github.com/emsesp/EMS-ESP32/discussions/2969) - support `minflowtemp` and `baseflowtemp` [#2969](https://github.com/emsesp/EMS-ESP32/discussions/2969)
- update version if it is 00.00 in first read [#2981](https://github.com/emsesp/EMS-ESP32/issues/2981)
- device class for % values [#2980](https://github.com/emsesp/EMS-ESP32/issues/2980)

View File

@@ -90,6 +90,10 @@ class EMSdevice {
return version_; return version_;
} }
void version(const char * version) {
strlcpy(version_, version, sizeof(version_));
}
uint8_t brand() const { uint8_t brand() const {
return brand_; return brand_;
} }

View File

@@ -1307,9 +1307,16 @@ bool EMSESP::add_device(const uint8_t device_id, const uint8_t product_id, const
// first check to see if we already have it, if so update the record // first check to see if we already have it, if so update the record
for (auto it = emsdevices.begin(); it != emsdevices.end(); ++it) { for (auto it = emsdevices.begin(); it != emsdevices.end(); ++it) {
if ((*it) && (*it)->is_device_id(device_id)) { if ((*it) && (*it)->is_device_id(device_id)) {
if (product_id == 0 || (*it)->product_id() != 0) { // update only with valid product_id if (product_id == 0) { // no product-id, ignore
return false;
}
if ((*it)->product_id() == product_id) { // update version if we have valid product_id
if (!strcmp((*it)->version(), "00.00")) {
(*it)->version(version);
}
return true; return true;
} }
// product-id has changed for this device-id, delete and re-add
(*it)->erase_device_values(); (*it)->erase_device_values();
emsdevices.erase(it); // erase the old device without product_id and re detect emsdevices.erase(it); // erase the old device without product_id and re detect
break; break;

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[ic_ha] = F_(iconpercent); // set icon
} }
doc[sc_ha] = sc_ha_measurement; 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; break;
case DeviceValueUOM::SECONDS: case DeviceValueUOM::SECONDS:
case DeviceValueUOM::MINUTES: 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 // add mf (manufacturer/brand), mdl (model), sw (software version) and via_device
dev_json["mf"] = brand != nullptr ? brand : "EMS-ESP"; dev_json["mf"] = brand != nullptr ? brand : "EMS-ESP";
dev_json["mdl"] = model != nullptr ? model : "EMS-ESP"; dev_json["mdl"] = model != nullptr ? model : "EMS-ESP";
dev_json["sw"] = version != nullptr ? version : "v" + std::string(EMSESP_APP_VERSION); dev_json["sw"] = version != nullptr ? version : "v" + std::string(EMSESP_APP_VERSION);
dev_json["via_device"] = Mqtt::basename(); dev_json["via_device"] = Mqtt::basename();
} }

View File

@@ -1 +1 @@
#define EMSESP_APP_VERSION "3.8.2-dev.9" #define EMSESP_APP_VERSION "3.8.2-dev.10"