diff --git a/CHANGELOG_LATEST.md b/CHANGELOG_LATEST.md index 01c26b5db..515c51710 100644 --- a/CHANGELOG_LATEST.md +++ b/CHANGELOG_LATEST.md @@ -3,11 +3,14 @@ ## Added - new command called `commands` which lists all available commands. `ems-esp/api/{device}/commands` +- Home Assistant icons for memory and time ## Fixed ## Changed - new API. Using secure access tokens and OpenAPI standard. See `doc/EMS-ESP32 API.md` and [#50](https://github.com/emsesp/EMS-ESP32/issues/50) +- `info` command always shows full names in API. For short names query the device or name directly, e.g. `http://ems-esp/api/boiler` +- free memory is shown in kilobytes ## Removed diff --git a/src/emsdevice.cpp b/src/emsdevice.cpp index 806434b34..208514f58 100644 --- a/src/emsdevice.cpp +++ b/src/emsdevice.cpp @@ -35,7 +35,9 @@ static const __FlashStringHelper * DeviceValueUOM_s[] __attribute__((__aligned__ F_(ua), F_(bar), F_(kw), - F_(w) + F_(w), + F_(kb), + F_(seconds) }; diff --git a/src/emsdevice.h b/src/emsdevice.h index bf103fe01..06a054d62 100644 --- a/src/emsdevice.h +++ b/src/emsdevice.h @@ -31,7 +31,6 @@ namespace emsesp { // Home Assistant icons (https://materialdesignicons.com/) -// MAKE_PSTR(icontemperature, "mdi:temperature-celsius") MAKE_PSTR(icontemperature, "mdi:coolant-temperature") MAKE_PSTR(iconpercent, "mdi:percent-outline") MAKE_PSTR(iconfire, "mdi:fire") @@ -40,6 +39,8 @@ MAKE_PSTR(iconflame, "mdi:flash") MAKE_PSTR(iconvalve, "mdi:valve") MAKE_PSTR(iconpump, "mdi:pump") MAKE_PSTR(iconheatpump, "mdi:water-pump") +MAKE_PSTR(iconclock, "mdi:clock-outline") +MAKE_PSTR(iconmemory, "mdi:memory") enum DeviceValueType : uint8_t { BOOL, @@ -57,7 +58,25 @@ enum DeviceValueType : uint8_t { // Unit Of Measurement mapping - maps to DeviceValueUOM_s in emsdevice.cpp // uom - also used with HA // sequence is important! -enum DeviceValueUOM : uint8_t { NONE = 0, DEGREES, PERCENT, LMIN, KWH, WH, HOURS, MINUTES, UA, BAR, KW, W, PUMP }; +enum DeviceValueUOM : uint8_t { + + NONE = 0, + DEGREES, + PERCENT, + LMIN, + KWH, + WH, + HOURS, + MINUTES, + UA, + BAR, + KW, + W, + KB, + SECONDS, + PUMP // special, do not remove + +}; // TAG mapping - maps to DeviceValueTAG_s in emsdevice.cpp enum DeviceValueTAG : uint8_t { diff --git a/src/locale_EN.h b/src/locale_EN.h index 46ea039f6..c7cd39c5c 100644 --- a/src/locale_EN.h +++ b/src/locale_EN.h @@ -168,6 +168,8 @@ MAKE_PSTR(ua, "uA") MAKE_PSTR(lmin, "l/min") MAKE_PSTR(kw, "kW") MAKE_PSTR(w, "W") +MAKE_PSTR(kb, "KB") +MAKE_PSTR(seconds, "seconds") // TAG mapping - maps to DeviceValueTAG_s in emsdevice.cpp // use empty string if want to suppress showing tags diff --git a/src/mqtt.cpp b/src/mqtt.cpp index d37d1a644..fa45d7b80 100644 --- a/src/mqtt.cpp +++ b/src/mqtt.cpp @@ -703,10 +703,15 @@ void Mqtt::ha_status() { // create the sensors // must match the MQTT payload keys - publish_mqtt_ha_sensor(DeviceValueType::INT, DeviceValueTAG::TAG_HEARTBEAT, F("WiFi strength"), EMSdevice::DeviceType::SYSTEM, F("rssi")); + publish_mqtt_ha_sensor(DeviceValueType::INT, DeviceValueTAG::TAG_HEARTBEAT, F("WiFi strength"), EMSdevice::DeviceType::SYSTEM, F("rssi"), DeviceValueUOM::PERCENT); publish_mqtt_ha_sensor(DeviceValueType::INT, DeviceValueTAG::TAG_HEARTBEAT, F("Uptime"), EMSdevice::DeviceType::SYSTEM, F("uptime")); - publish_mqtt_ha_sensor(DeviceValueType::INT, DeviceValueTAG::TAG_HEARTBEAT, F("Uptime (sec)"), EMSdevice::DeviceType::SYSTEM, F("uptime_sec")); - publish_mqtt_ha_sensor(DeviceValueType::INT, DeviceValueTAG::TAG_HEARTBEAT, F("Free memory"), EMSdevice::DeviceType::SYSTEM, F("freemem")); + publish_mqtt_ha_sensor(DeviceValueType::INT, + DeviceValueTAG::TAG_HEARTBEAT, + F("Uptime (sec)"), + EMSdevice::DeviceType::SYSTEM, + F("uptime_sec"), + DeviceValueUOM::SECONDS); + publish_mqtt_ha_sensor(DeviceValueType::INT, DeviceValueTAG::TAG_HEARTBEAT, F("Free memory"), EMSdevice::DeviceType::SYSTEM, F("freemem"), DeviceValueUOM::KB); publish_mqtt_ha_sensor(DeviceValueType::INT, DeviceValueTAG::TAG_HEARTBEAT, F("# MQTT fails"), EMSdevice::DeviceType::SYSTEM, F("mqttfails")); publish_mqtt_ha_sensor(DeviceValueType::INT, DeviceValueTAG::TAG_HEARTBEAT, F("# Rx received"), EMSdevice::DeviceType::SYSTEM, F("rxreceived")); publish_mqtt_ha_sensor(DeviceValueType::INT, DeviceValueTAG::TAG_HEARTBEAT, F("# Rx fails"), EMSdevice::DeviceType::SYSTEM, F("rxfails")); @@ -1002,6 +1007,14 @@ void Mqtt::publish_mqtt_ha_sensor(uint8_t type, // EMSdevice case DeviceValueUOM::PUMP: doc["ic"] = F_(iconpump); break; + case DeviceValueUOM::SECONDS: + case DeviceValueUOM::MINUTES: + case DeviceValueUOM::HOURS: + doc["ic"] = F_(iconclock); + break; + case DeviceValueUOM::KB: + doc["ic"] = F_(iconmemory); + break; case DeviceValueUOM::NONE: default: break; diff --git a/src/system.cpp b/src/system.cpp index 1285c8124..d582c65ce 100644 --- a/src/system.cpp +++ b/src/system.cpp @@ -474,7 +474,7 @@ bool System::heartbeat_json(JsonObject & doc) { doc["dallasfails"] = EMSESP::sensor_fails(); } #ifndef EMSESP_STANDALONE - doc["freemem"] = ESP.getFreeHeap(); + doc["freemem"] = ESP.getFreeHeap() / 1000L; // kilobytes #endif if (analog_enabled_) { @@ -893,7 +893,7 @@ bool System::command_info(const char * value, const int8_t id, JsonObject & json node["version"] = EMSESP_APP_VERSION; node["uptime"] = uuid::log::format_timestamp_ms(uuid::get_uptime_ms(), 3); #ifndef EMSESP_STANDALONE - node["freemem"] = ESP.getFreeHeap(); + node["freemem"] = ESP.getFreeHeap() / 1000L; // kilobytes #endif node = json.createNestedObject("Status");