Merge pull request #134 from proddy/dev

Dev
This commit is contained in:
Proddy
2021-09-28 16:18:30 +02:00
committed by GitHub
6 changed files with 28 additions and 28 deletions

View File

@@ -9,7 +9,8 @@
- Add RC300 second summermode telegram [#108](https://github.com/emsesp/EMS-ESP32/issues/108) - Add RC300 second summermode telegram [#108](https://github.com/emsesp/EMS-ESP32/issues/108)
- Add support for the RC25 thermostat [#106](https://github.com/emsesp/EMS-ESP32/issues/106) - Add support for the RC25 thermostat [#106](https://github.com/emsesp/EMS-ESP32/issues/106)
- Add new command 'entities' for a device, e.g. http://ems-esp/api/boiler/entities to show the shortname, description and HA Entity name (if HA enabled) [#116](https://github.com/emsesp/EMS-ESP32/issues/116) - Add new command 'entities' for a device, e.g. http://ems-esp/api/boiler/entities to show the shortname, description and HA Entity name (if HA enabled) [#116](https://github.com/emsesp/EMS-ESP32/issues/116)
- Junkers program and remote (fb10/fb110) temperature - Support for Junkers program and remote (fb10/fb110) temperature
- Home Assistant `state_class` attribute for Wh, kWh, W and KW [#129](https://github.com/emsesp/EMS-ESP32/issues/129)
## Fixed ## Fixed
@@ -25,7 +26,7 @@
- rename `fastheatupfactor` to `fastheatup` and add percent [#122] - rename `fastheatupfactor` to `fastheatup` and add percent [#122]
- "unit" renamed to "uom" in API call to recall a Device Value - "unit" renamed to "uom" in API call to recall a Device Value
- initial backend React changes to replace the class components (HOCs) with React Hooks - initial backend React changes to replace the class components (HOCs) with React Hooks
- program-names instead of numbers - Use program-names instead of numbers
## **BREAKING CHANGES** ## **BREAKING CHANGES**

View File

@@ -16,7 +16,7 @@ my_build_flags =
; upload_port = 10.10.10.101 ; upload_port = 10.10.10.101
; to prevent the web UI from building each time, comment out this next line ; to prevent the web UI from building each time, comment out this next line
extra_scripts = extra_scripts = scripts/rename_fw.py ; don't build WebUI
; pio run -e debug ; pio run -e debug
; or from Visual Studio Code do PIO -> Project Tasks -> debug -> General -> Upload and Monitor ; or from Visual Studio Code do PIO -> Project Tasks -> debug -> General -> Upload and Monitor

View File

@@ -1051,7 +1051,7 @@ bool EMSdevice::generate_values_json(JsonObject & root, const uint8_t tag_filter
void EMSdevice::publish_mqtt_ha_sensor() { void EMSdevice::publish_mqtt_ha_sensor() {
for (auto & dv : devicevalues_) { for (auto & dv : devicevalues_) {
if (dv.ha == DeviceValueHA::HA_VALUE) { if (dv.ha == DeviceValueHA::HA_VALUE) {
Mqtt::publish_ha_sensor(dv.type, dv.tag, dv.full_name, device_type_, dv.short_name, dv.uom); Mqtt::publish_ha_sensor(dv.type, dv.tag, dv.full_name, dv.device_type, dv.short_name, dv.uom, dv.has_cmd);
dv.ha |= DeviceValueHA::HA_DONE; dv.ha |= DeviceValueHA::HA_DONE;
} }
} }

View File

@@ -721,7 +721,7 @@ void Mqtt::ha_status() {
DeviceValueUOM::PERCENT); DeviceValueUOM::PERCENT);
} }
publish_ha_sensor(DeviceValueType::INT, DeviceValueTAG::TAG_HEARTBEAT, F("Uptime"), EMSdevice::DeviceType::SYSTEM, F("uptime")); publish_ha_sensor(DeviceValueType::INT, DeviceValueTAG::TAG_HEARTBEAT, F("Uptime"), EMSdevice::DeviceType::SYSTEM, F("uptime"), DeviceValueUOM::NONE);
publish_ha_sensor(DeviceValueType::INT, DeviceValueTAG::TAG_HEARTBEAT, F("Uptime (sec)"), EMSdevice::DeviceType::SYSTEM, F("uptime_sec"), DeviceValueUOM::SECONDS); publish_ha_sensor(DeviceValueType::INT, DeviceValueTAG::TAG_HEARTBEAT, F("Uptime (sec)"), EMSdevice::DeviceType::SYSTEM, F("uptime_sec"), DeviceValueUOM::SECONDS);
publish_ha_sensor(DeviceValueType::INT, DeviceValueTAG::TAG_HEARTBEAT, F("Free memory"), EMSdevice::DeviceType::SYSTEM, F("freemem"), DeviceValueUOM::KB); publish_ha_sensor(DeviceValueType::INT, DeviceValueTAG::TAG_HEARTBEAT, F("Free memory"), EMSdevice::DeviceType::SYSTEM, F("freemem"), DeviceValueUOM::KB);
publish_ha_sensor(DeviceValueType::INT, DeviceValueTAG::TAG_HEARTBEAT, F("# MQTT fails"), EMSdevice::DeviceType::SYSTEM, F("mqttfails"), DeviceValueUOM::NONE); publish_ha_sensor(DeviceValueType::INT, DeviceValueTAG::TAG_HEARTBEAT, F("# MQTT fails"), EMSdevice::DeviceType::SYSTEM, F("mqttfails"), DeviceValueUOM::NONE);
@@ -929,7 +929,8 @@ void Mqtt::publish_ha_sensor(uint8_t type, // EMSdevice::Dev
const __FlashStringHelper * name, const __FlashStringHelper * name,
const uint8_t device_type, // EMSdevice::DeviceType const uint8_t device_type, // EMSdevice::DeviceType
const __FlashStringHelper * entity, const __FlashStringHelper * entity,
const uint8_t uom) { // EMSdevice::DeviceValueUOM (0=NONE) const uint8_t uom, // EMSdevice::DeviceValueUOM (0=NONE)
const bool has_cmd) {
// ignore if name (fullname) is empty // ignore if name (fullname) is empty
if (name == nullptr) { if (name == nullptr) {
return; return;
@@ -1002,8 +1003,8 @@ void Mqtt::publish_ha_sensor(uint8_t type, // EMSdevice::Dev
// normal HA sensor, not a boolean one // normal HA sensor, not a boolean one
snprintf(topic, sizeof(topic), "sensor/%s/%s/config", mqtt_base_.c_str(), uniq.c_str()); // topic snprintf(topic, sizeof(topic), "sensor/%s/%s/config", mqtt_base_.c_str(), uniq.c_str()); // topic
uint8_t set_state_class = 0; enum uint8_t { STATE_CLASS_NONE, STATE_CLASS_MEASUREMENT, STATE_CLASS_TOTAL_INCREASING };
enum uint8_t { MEASURE = 1, TOTAL }; uint8_t set_state_class = STATE_CLASS_NONE; // default
// unit of measure and map the HA icon // unit of measure and map the HA icon
if (uom != DeviceValueUOM::NONE) { if (uom != DeviceValueUOM::NONE) {
@@ -1012,12 +1013,10 @@ void Mqtt::publish_ha_sensor(uint8_t type, // EMSdevice::Dev
switch (uom) { switch (uom) {
case DeviceValueUOM::DEGREES: case DeviceValueUOM::DEGREES:
doc["ic"] = F_(icondegrees); doc["ic"] = F_(icondegrees);
set_state_class = MEASURE;
break; break;
case DeviceValueUOM::PERCENT: case DeviceValueUOM::PERCENT:
doc["ic"] = F_(iconpercent); doc["ic"] = F_(iconpercent);
set_state_class = MEASURE;
break; break;
case DeviceValueUOM::SECONDS: case DeviceValueUOM::SECONDS:
case DeviceValueUOM::MINUTES: case DeviceValueUOM::MINUTES:
@@ -1028,26 +1027,23 @@ void Mqtt::publish_ha_sensor(uint8_t type, // EMSdevice::Dev
doc["ic"] = F_(iconkb); doc["ic"] = F_(iconkb);
break; break;
case DeviceValueUOM::LMIN: case DeviceValueUOM::LMIN:
doc["ic"] = F_(iconlmin); doc["ic"] = F_(iconlmin);
set_state_class = MEASURE;
break; break;
case DeviceValueUOM::WH: case DeviceValueUOM::WH:
case DeviceValueUOM::KWH: case DeviceValueUOM::KWH:
doc["ic"] = F_(iconkwh); doc["ic"] = F_(iconkwh);
set_state_class = TOTAL; set_state_class = STATE_CLASS_TOTAL_INCREASING;
break; break;
case DeviceValueUOM::UA: case DeviceValueUOM::UA:
doc["ic"] = F_(iconua); doc["ic"] = F_(iconua);
set_state_class = MEASURE;
break; break;
case DeviceValueUOM::BAR: case DeviceValueUOM::BAR:
doc["ic"] = F_(iconbar); doc["ic"] = F_(iconbar);
set_state_class = MEASURE;
break; break;
case DeviceValueUOM::W: case DeviceValueUOM::W:
case DeviceValueUOM::KW: case DeviceValueUOM::KW:
doc["ic"] = F_(iconkw); doc["ic"] = F_(iconkw);
set_state_class = MEASURE; set_state_class = STATE_CLASS_MEASUREMENT;
break; break;
case DeviceValueUOM::DBM: case DeviceValueUOM::DBM:
doc["ic"] = F_(icondbm); doc["ic"] = F_(icondbm);
@@ -1055,18 +1051,20 @@ void Mqtt::publish_ha_sensor(uint8_t type, // EMSdevice::Dev
case DeviceValueUOM::NONE: case DeviceValueUOM::NONE:
if (type == DeviceValueType::INT || type == DeviceValueType::UINT || type == DeviceValueType::SHORT || type == DeviceValueType::USHORT if (type == DeviceValueType::INT || type == DeviceValueType::UINT || type == DeviceValueType::SHORT || type == DeviceValueType::USHORT
|| type == DeviceValueType::ULONG) { || type == DeviceValueType::ULONG) {
doc["ic"] = F_(iconnum); doc["ic"] = F_(iconnum);
set_state_class = TOTAL;
} }
default: default:
break; break;
} }
// see if we need to set the state_class // see if we need to set the state_class
if (set_state_class == MEASURE) { // ignore any commands
doc["state_class"] = F("measurement"); if (!has_cmd) {
} else if (set_state_class == TOTAL) { if (set_state_class == STATE_CLASS_MEASUREMENT) {
doc["state_class"] = F("total_increasing"); doc["state_class"] = F("measurement");
} else if (set_state_class == STATE_CLASS_TOTAL_INCREASING) {
doc["state_class"] = F("total_increasing");
}
} }
} }

View File

@@ -121,7 +121,8 @@ class Mqtt {
const __FlashStringHelper * name, const __FlashStringHelper * name,
const uint8_t device_type, const uint8_t device_type,
const __FlashStringHelper * entity, const __FlashStringHelper * entity,
const uint8_t uom = 0); const uint8_t uom,
const bool has_cmd = false);
static void register_command(const uint8_t device_type, const __FlashStringHelper * cmd, cmdfunction_p cb, uint8_t flags = 0); static void register_command(const uint8_t device_type, const __FlashStringHelper * cmd, cmdfunction_p cb, uint8_t flags = 0);
static void show_topic_handlers(uuid::console::Shell & shell, const uint8_t device_type); static void show_topic_handlers(uuid::console::Shell & shell, const uint8_t device_type);

View File

@@ -1 +1 @@
#define EMSESP_APP_VERSION "3.2.2b8" #define EMSESP_APP_VERSION "3.2.2b10"