mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-06 07:49:52 +03:00
show freemem in KB, add more HA icons
This commit is contained in:
@@ -34,7 +34,9 @@ static const __FlashStringHelper * DeviceValueUOM_s[] __attribute__((__aligned__
|
||||
F_(minutes),
|
||||
F_(ua),
|
||||
F_(bar),
|
||||
F_(kw)
|
||||
F_(kw),
|
||||
F_(kb),
|
||||
F_(seconds)
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -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,24 @@ 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, PUMP };
|
||||
enum DeviceValueUOM : uint8_t {
|
||||
|
||||
NONE = 0,
|
||||
DEGREES,
|
||||
PERCENT,
|
||||
LMIN,
|
||||
KWH,
|
||||
WH,
|
||||
HOURS,
|
||||
MINUTES,
|
||||
UA,
|
||||
BAR,
|
||||
KW,
|
||||
KB,
|
||||
SECONDS,
|
||||
PUMP // special, do not remove
|
||||
|
||||
};
|
||||
|
||||
// TAG mapping - maps to DeviceValueTAG_s in emsdevice.cpp
|
||||
enum DeviceValueTAG : uint8_t {
|
||||
|
||||
@@ -165,6 +165,8 @@ MAKE_PSTR(hours, "hours")
|
||||
MAKE_PSTR(ua, "uA")
|
||||
MAKE_PSTR(lmin, "l/min")
|
||||
MAKE_PSTR(kw, "kW")
|
||||
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
|
||||
|
||||
19
src/mqtt.cpp
19
src/mqtt.cpp
@@ -709,10 +709,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"));
|
||||
@@ -1008,6 +1013,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;
|
||||
|
||||
@@ -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_) {
|
||||
@@ -897,7 +897,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");
|
||||
|
||||
Reference in New Issue
Block a user