From 1bd834924afd694edc6ff286cfe9e192de504399 Mon Sep 17 00:00:00 2001 From: proddy Date: Sun, 25 Apr 2021 09:53:45 +0200 Subject: [PATCH] auto formatting --- CHANGELOG_LATEST.md | 3 ++- src/devices/boiler.cpp | 2 +- src/devices/solar.cpp | 1 - src/devices/solar.h | 4 +++- src/emsdevice.cpp | 50 +++++++++++++++++++++--------------------- 5 files changed, 31 insertions(+), 29 deletions(-) diff --git a/CHANGELOG_LATEST.md b/CHANGELOG_LATEST.md index 45a7de9b9..0581d30d0 100644 --- a/CHANGELOG_LATEST.md +++ b/CHANGELOG_LATEST.md @@ -5,9 +5,10 @@ - Mock API to simulate an ESP, for testing web - Able to write values from the Web UI - check values with `"cmd":` and data empty or `?` -- set hc for values and commands by id or prefix `hc`+separarator, separator can be any char +- set hc for values and commands by id or prefix `hc`+separator, separator can be any char ## Fixed + - Don't create Home Assistant MQTT discovery entries for device values that don't exists (#756 on EMS-ESP repo) - Update shower MQTT when a shower start is detected - S32 board profile diff --git a/src/devices/boiler.cpp b/src/devices/boiler.cpp index e7ae503b5..383ebc6eb 100644 --- a/src/devices/boiler.cpp +++ b/src/devices/boiler.cpp @@ -1115,7 +1115,7 @@ bool Boiler::set_warmwater_circulation_mode(const char * value, const int8_t id) // 8 reset maintenance message Hxx // 12 & 13 Reset that Error-memory bool Boiler::set_reset(const char * value, const int8_t id) { - uint8_t num; + uint8_t num; if (!Helpers::value2enum(value, num, FL_(enum_reset))) { return false; } diff --git a/src/devices/solar.cpp b/src/devices/solar.cpp index a132a4d8a..ce0fe1284 100644 --- a/src/devices/solar.cpp +++ b/src/devices/solar.cpp @@ -95,7 +95,6 @@ Solar::Solar(uint8_t device_type, uint8_t device_id, uint8_t product_id, const s register_device_value(TAG_NONE, &energyLastHour_, DeviceValueType::ULONG, FL_(div10), FL_(energyLastHour), DeviceValueUOM::WH); register_device_value(TAG_NONE, &energyTotal_, DeviceValueType::ULONG, FL_(div10), FL_(energyTotal), DeviceValueUOM::KWH); register_device_value(TAG_NONE, &energyToday_, DeviceValueType::ULONG, nullptr, FL_(energyToday), DeviceValueUOM::WH); - } // publish HA config diff --git a/src/devices/solar.h b/src/devices/solar.h index d7bb38eb0..38631b427 100644 --- a/src/devices/solar.h +++ b/src/devices/solar.h @@ -75,12 +75,14 @@ class Solar : public EMSdevice { uint8_t climateZone_; // climate zone identifier uint16_t collector1Area_; // Area of collector field 1 uint8_t collector1Type_; // Type of collector field 1, 01=flat, 02=vacuum - // SM100wwTemperature - 0x07D6 + + // SM100wwTemperature - 0x07D6 uint8_t wwTemp_1_; uint8_t wwTemp_3_; uint8_t wwTemp_4_; uint8_t wwTemp_5_; uint8_t wwTemp_7_; + // SM100wwStatus - 0x07AA uint8_t wwPump_; diff --git a/src/emsdevice.cpp b/src/emsdevice.cpp index 000e97eb8..9bdffff51 100644 --- a/src/emsdevice.cpp +++ b/src/emsdevice.cpp @@ -651,7 +651,7 @@ bool EMSdevice::get_value_info(JsonObject & root, const char * cmd, const int8_t for (auto & dv : devicevalues_) { if (strcmp(cmd, uuid::read_flash_string(dv.short_name).c_str()) == 0 && (tag <= 0 || tag == dv.tag)) { uint8_t divider = (dv.options_size == 1) ? Helpers::atoint(uuid::read_flash_string(dv.options[0]).c_str()) : 0; - json["name"] = dv.short_name; + json["name"] = dv.short_name; if (dv.tag >= DeviceValueTAG::TAG_HC1) { json["circuit"] = tag_to_string(dv.tag); } @@ -675,16 +675,16 @@ bool EMSdevice::get_value_info(JsonObject & root, const char * cmd, const int8_t if (Helpers::hasValue(*(uint16_t *)(dv.value_p))) { json["value"] = Helpers::round2(*(uint16_t *)(dv.value_p), divider); } - json["type"] = F_(number); - json["min"] = 0; - json["max"] = divider ? EMS_VALUE_USHORT_NOTSET / divider : EMS_VALUE_USHORT_NOTSET; + json["type"] = F_(number); + json["min"] = 0; + json["max"] = divider ? EMS_VALUE_USHORT_NOTSET / divider : EMS_VALUE_USHORT_NOTSET; break; case DeviceValueType::UINT: if (Helpers::hasValue(*(uint8_t *)(dv.value_p))) { json["value"] = Helpers::round2(*(uint8_t *)(dv.value_p), divider); } - json["type"] = F_(number); - json["min"] = 0; + json["type"] = F_(number); + json["min"] = 0; if (dv.uom == DeviceValueUOM::PERCENT) { json["max"] = 100; } else { @@ -695,15 +695,15 @@ bool EMSdevice::get_value_info(JsonObject & root, const char * cmd, const int8_t if (Helpers::hasValue(*(int16_t *)(dv.value_p))) { json["value"] = Helpers::round2(*(int16_t *)(dv.value_p), divider); } - json["type"] = F_(number); - json["min"] = divider ? -EMS_VALUE_SHORT_NOTSET / divider : -EMS_VALUE_SHORT_NOTSET; - json["max"] = divider ? EMS_VALUE_SHORT_NOTSET / divider : EMS_VALUE_SHORT_NOTSET; + json["type"] = F_(number); + json["min"] = divider ? -EMS_VALUE_SHORT_NOTSET / divider : -EMS_VALUE_SHORT_NOTSET; + json["max"] = divider ? EMS_VALUE_SHORT_NOTSET / divider : EMS_VALUE_SHORT_NOTSET; break; case DeviceValueType::INT: if (Helpers::hasValue(*(int8_t *)(dv.value_p))) { json["value"] = Helpers::round2(*(int8_t *)(dv.value_p), divider); } - json["type"] = F_(number); + json["type"] = F_(number); if (dv.uom == DeviceValueUOM::PERCENT) { json["min"] = -100; json["max"] = 100; @@ -716,17 +716,17 @@ bool EMSdevice::get_value_info(JsonObject & root, const char * cmd, const int8_t if (Helpers::hasValue(*(uint32_t *)(dv.value_p))) { json["value"] = Helpers::round2(*(uint32_t *)(dv.value_p), divider); } - json["type"] = F_(number); - json["min"] = 0; - json["max"] = divider ? EMS_VALUE_ULONG_NOTSET / divider : EMS_VALUE_ULONG_NOTSET; + json["type"] = F_(number); + json["min"] = 0; + json["max"] = divider ? EMS_VALUE_ULONG_NOTSET / divider : EMS_VALUE_ULONG_NOTSET; break; case DeviceValueType::BOOL: { if (Helpers::hasValue(*(uint8_t *)(dv.value_p), EMS_VALUE_BOOL)) { json["value"] = (bool)(*(uint8_t *)(dv.value_p)) ? true : false; } - json["type"] = F("boolean"); - json["min"] = 0; - json["max"] = 1; + json["type"] = F("boolean"); + json["min"] = 0; + json["max"] = 1; JsonArray enum_ = json.createNestedArray(F("enum")); if (dv.options_size == 2) { enum_.add(dv.options[1]); @@ -747,18 +747,18 @@ bool EMSdevice::get_value_info(JsonObject & root, const char * cmd, const int8_t if (Helpers::hasValue(*(uint32_t *)(dv.value_p))) { json["value"] = (divider) ? *(uint32_t *)(dv.value_p) / divider : *(uint32_t *)(dv.value_p); } - json["type"] = F_(number); - json["min"] = 0; - json["max"] = divider ? EMS_VALUE_ULONG_NOTSET / divider : EMS_VALUE_ULONG_NOTSET; + json["type"] = F_(number); + json["min"] = 0; + json["max"] = divider ? EMS_VALUE_ULONG_NOTSET / divider : EMS_VALUE_ULONG_NOTSET; break; case DeviceValueType::TEXT: if (Helpers::hasValue((char *)(dv.value_p))) { json["value"] = (char *)(dv.value_p); } - json["type"] = F_(text); + json["type"] = F_(text); break; default: - json["type"] = F_(unknown); + json["type"] = F_(unknown); break; } if (dv.uom != DeviceValueUOM::NONE) { @@ -766,10 +766,10 @@ bool EMSdevice::get_value_info(JsonObject & root, const char * cmd, const int8_t } json["writeable"] = dv.has_cmd; if (dv.min != 0 || dv.max != 0) { - json["min"] = dv.min; - json["max"] = dv.max; + json["min"] = dv.min; + json["max"] = dv.max; } - return true; + return true; } } return false; @@ -916,7 +916,7 @@ bool EMSdevice::generate_values_json(JsonObject & root, const uint8_t tag_filter } } } - dv.ha |= has_value ? DeviceValueHA::HA_VALUE : DeviceValueHA::HA_NONE; + dv.ha |= has_value ? DeviceValueHA::HA_VALUE : DeviceValueHA::HA_NONE; has_values |= has_value; }