Merge branch 'dev' of https://github.com/emsesp/EMS-ESP32 into dev_cmd

This commit is contained in:
MichaelDvP
2021-05-10 15:40:14 +02:00
6 changed files with 47 additions and 8 deletions

View File

@@ -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

View File

@@ -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)
};

View File

@@ -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 {

View File

@@ -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

View File

@@ -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;

View File

@@ -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");