mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-07 00:09:51 +03:00
fixed #129
This commit is contained in:
@@ -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**
|
||||||
|
|
||||||
|
|||||||
@@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
26
src/mqtt.cpp
26
src/mqtt.cpp
@@ -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) {
|
||||||
@@ -1013,11 +1014,9 @@ 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:
|
||||||
@@ -1029,25 +1028,22 @@ void Mqtt::publish_ha_sensor(uint8_t type, // EMSdevice::Dev
|
|||||||
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);
|
||||||
@@ -1056,19 +1052,21 @@ void Mqtt::publish_ha_sensor(uint8_t type, // EMSdevice::Dev
|
|||||||
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
|
||||||
|
if (!has_cmd) {
|
||||||
|
if (set_state_class == STATE_CLASS_MEASUREMENT) {
|
||||||
doc["state_class"] = F("measurement");
|
doc["state_class"] = F("measurement");
|
||||||
} else if (set_state_class == TOTAL) {
|
} else if (set_state_class == STATE_CLASS_TOTAL_INCREASING) {
|
||||||
doc["state_class"] = F("total_increasing");
|
doc["state_class"] = F("total_increasing");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
JsonObject dev = doc.createNestedObject("dev");
|
JsonObject dev = doc.createNestedObject("dev");
|
||||||
JsonArray ids = dev.createNestedArray("ids");
|
JsonArray ids = dev.createNestedArray("ids");
|
||||||
|
|||||||
@@ -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);
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
#define EMSESP_APP_VERSION "3.2.2b8"
|
#define EMSESP_APP_VERSION "3.2.2b10"
|
||||||
|
|||||||
Reference in New Issue
Block a user