From 45b6779efb1b7d2ab9b3fcf9ca4f0c48f2bbb96d Mon Sep 17 00:00:00 2001 From: CaCO3 Date: Sat, 12 Oct 2024 22:39:27 +0200 Subject: [PATCH 1/7] Update the Homeasistantr Discovery topics to comply with Homeasistant 2024.10 - "raw" should have a "State Class" unlike "". -> Set it to "measurement" since it could be decreasing as well as increasing. Further changes: - "value" should only have "State Class"="total_increasing" if "Allow Negative Rates" is NOT set. Else it should use "measurement" as it could go down again. --- code/components/jomjol_mqtt/server_mqtt.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/code/components/jomjol_mqtt/server_mqtt.cpp b/code/components/jomjol_mqtt/server_mqtt.cpp index fd675a139..e7de125ca 100644 --- a/code/components/jomjol_mqtt/server_mqtt.cpp +++ b/code/components/jomjol_mqtt/server_mqtt.cpp @@ -184,9 +184,14 @@ bool MQTThomeassistantDiscovery(int qos) { group = ""; } + std::string value_state_class = "total_increasing"; + if ((*NUMBERS)[i]->AllowNegativeRates) { + value_state_class = "measurement"; + } + // Group | Field | User Friendly Name | Icon | Unit | Device Class | State Class | Entity Category - allSendsSuccessed |= sendHomeAssistantDiscoveryTopic(group, "value", "Value", "gauge", valueUnit, meterType, "total_increasing", "", qos); - allSendsSuccessed |= sendHomeAssistantDiscoveryTopic(group, "raw", "Raw Value", "raw", "", "", "", "diagnostic", qos); + allSendsSuccessed |= sendHomeAssistantDiscoveryTopic(group, "value", "Value", "gauge", valueUnit, meterType, value_state_class, "", qos); // State Class = "total_increasing" if .AllowNegativeRates = false, else use "measurement" + allSendsSuccessed |= sendHomeAssistantDiscoveryTopic(group, "raw", "Raw Value", "raw", valueUnit, meterType, "measurement", "diagnostic", qos); allSendsSuccessed |= sendHomeAssistantDiscoveryTopic(group, "error", "Error", "alert-circle-outline", "", "", "", "diagnostic", qos); /* Not announcing "rate" as it is better to use rate_per_time_unit resp. rate_per_digitization_round */ // allSendsSuccessed |= sendHomeAssistantDiscoveryTopic(group, "rate", "Rate (Unit/Minute)", "swap-vertical", "", "", "", ""); // Legacy, always Unit per Minute From 76d47f6a8c8168d9bb179e32bcb3d1287c40d6be Mon Sep 17 00:00:00 2001 From: CaCO3 Date: Sat, 12 Oct 2024 23:11:14 +0200 Subject: [PATCH 2/7] updated comment --- code/components/jomjol_flowcontroll/ClassFlowMQTT.cpp | 4 ++-- code/components/jomjol_mqtt/server_mqtt.cpp | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/code/components/jomjol_flowcontroll/ClassFlowMQTT.cpp b/code/components/jomjol_flowcontroll/ClassFlowMQTT.cpp index d798d3eba..83b8ba1d8 100644 --- a/code/components/jomjol_flowcontroll/ClassFlowMQTT.cpp +++ b/code/components/jomjol_flowcontroll/ClassFlowMQTT.cpp @@ -151,7 +151,7 @@ bool ClassFlowMQTT::ReadParameter(FILE* pfile, string& aktparamgraph) mqttServer_setMeterType("water", "L", "h", "L/h"); } else if (toUpper(splitted[1]) == "WATER_FT3") { - mqttServer_setMeterType("water", "ft³", "m", "ft³/m"); // Minutes + mqttServer_setMeterType("water", "ft³", "m", "ft³/m"); // m = Minutes } else if (toUpper(splitted[1]) == "WATER_GAL") { mqttServer_setMeterType("water", "gal", "h", "gal/h"); @@ -160,7 +160,7 @@ bool ClassFlowMQTT::ReadParameter(FILE* pfile, string& aktparamgraph) mqttServer_setMeterType("gas", "m³", "h", "m³/h"); } else if (toUpper(splitted[1]) == "GAS_FT3") { - mqttServer_setMeterType("gas", "ft³", "m", "ft³/m"); // Minutes + mqttServer_setMeterType("gas", "ft³", "m", "ft³/m"); // m = Minutes } else if (toUpper(splitted[1]) == "ENERGY_WH") { mqttServer_setMeterType("energy", "Wh", "h", "W"); diff --git a/code/components/jomjol_mqtt/server_mqtt.cpp b/code/components/jomjol_mqtt/server_mqtt.cpp index e7de125ca..84bdb3ee7 100644 --- a/code/components/jomjol_mqtt/server_mqtt.cpp +++ b/code/components/jomjol_mqtt/server_mqtt.cpp @@ -184,6 +184,7 @@ bool MQTThomeassistantDiscovery(int qos) { group = ""; } + /* If "Allow neg. rate" is true, use "measurement" instead of "total_increasing" for the State Class, see https://github.com/jomjol/AI-on-the-edge-device/issues/3331 */ std::string value_state_class = "total_increasing"; if ((*NUMBERS)[i]->AllowNegativeRates) { value_state_class = "measurement"; From a78786a2d2a4f1396f367ad3d9d570dd35ddeec7 Mon Sep 17 00:00:00 2001 From: CaCO3 Date: Sat, 12 Oct 2024 23:11:51 +0200 Subject: [PATCH 3/7] Energy meters need a different Device Class --- code/components/jomjol_mqtt/server_mqtt.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/code/components/jomjol_mqtt/server_mqtt.cpp b/code/components/jomjol_mqtt/server_mqtt.cpp index 84bdb3ee7..728689832 100644 --- a/code/components/jomjol_mqtt/server_mqtt.cpp +++ b/code/components/jomjol_mqtt/server_mqtt.cpp @@ -190,13 +190,19 @@ bool MQTThomeassistantDiscovery(int qos) { value_state_class = "measurement"; } + /* Energy meters need a different Device Class, see https://github.com/jomjol/AI-on-the-edge-device/issues/3333 */ + std::string rate_device_class = "volume_flow_rate"; + if (meterType == "energy") { + value_state_class = "power"; + } + // Group | Field | User Friendly Name | Icon | Unit | Device Class | State Class | Entity Category allSendsSuccessed |= sendHomeAssistantDiscoveryTopic(group, "value", "Value", "gauge", valueUnit, meterType, value_state_class, "", qos); // State Class = "total_increasing" if .AllowNegativeRates = false, else use "measurement" allSendsSuccessed |= sendHomeAssistantDiscoveryTopic(group, "raw", "Raw Value", "raw", valueUnit, meterType, "measurement", "diagnostic", qos); allSendsSuccessed |= sendHomeAssistantDiscoveryTopic(group, "error", "Error", "alert-circle-outline", "", "", "", "diagnostic", qos); /* Not announcing "rate" as it is better to use rate_per_time_unit resp. rate_per_digitization_round */ // allSendsSuccessed |= sendHomeAssistantDiscoveryTopic(group, "rate", "Rate (Unit/Minute)", "swap-vertical", "", "", "", ""); // Legacy, always Unit per Minute - allSendsSuccessed |= sendHomeAssistantDiscoveryTopic(group, "rate_per_time_unit", "Rate (" + rateUnit + ")", "swap-vertical", rateUnit, "", "measurement", "", qos); + allSendsSuccessed |= sendHomeAssistantDiscoveryTopic(group, "rate_per_time_unit", "Rate (" + rateUnit + ")", "swap-vertical", rateUnit, rate_device_class, "measurement", "", qos); allSendsSuccessed |= sendHomeAssistantDiscoveryTopic(group, "rate_per_digitization_round", "Change since last Digitization round", "arrow-expand-vertical", valueUnit, "", "measurement", "", qos); // correctly the Unit is Unit/Interval! allSendsSuccessed |= sendHomeAssistantDiscoveryTopic(group, "timestamp", "Timestamp", "clock-time-eight-outline", "", "timestamp", "", "diagnostic", qos); allSendsSuccessed |= sendHomeAssistantDiscoveryTopic(group, "json", "JSON", "code-json", "", "", "", "diagnostic", qos); From 77c07e1127386f7459b95d478ec8f8e5a4486eee Mon Sep 17 00:00:00 2001 From: CaCO3 Date: Sat, 12 Oct 2024 23:34:39 +0200 Subject: [PATCH 4/7] Update changelog --- Changelog.md | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/Changelog.md b/Changelog.md index 84aaf6a7c..9b48dfb21 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,3 +1,25 @@ +## [16.0.0-RC5] - 2024-10-xx + +For a full list of changes see [Full list of changes](https://github.com/jomjol/AI-on-the-edge-device/compare/v15.7.0...v16.0.0-RC1) + +#### Known issues +Please check the [issues](https://github.com/jomjol/AI-on-the-edge-device/issues) and +[discussions](https://github.com/jomjol/AI-on-the-edge-device/discussions) before reporting a new issue. + +#### Core Changes +Only changes since RC4 are listed: +- Updated the Homeasistant Discovery topics (#3332) + - `raw` has now set the `State Class` to `measurement`. Before the `State Class` was always set to `""`. + - `value` has now only set the `State Class` to `total_increasing` if `Allow Negative Rates` is NOT set. Else it uses `measurement` as it could go down. Before it was always set to `total_increasing`. + - The `rate_per_time_unit` topic of an **Energy** meter needs a `Device Class`=`power`. For `gas` and `water` it should be `volume_flow_rate`. Before the `Device Class` was always set to `""`. + +#### Bug Fixes +Only changes since RC3 are listed: + - None + + + + ## [16.0.0-RC4] - 2024-10-06 For a full list of changes see [Full list of changes](https://github.com/jomjol/AI-on-the-edge-device/compare/v15.7.0...v16.0.0-RC1) @@ -7,7 +29,7 @@ Please check the [issues](https://github.com/jomjol/AI-on-the-edge-device/issues [discussions](https://github.com/jomjol/AI-on-the-edge-device/discussions) before reporting a new issue. #### Core Changes -Only changes since RC2 are listed: +Only changes since RC3 are listed: - Update esp32-camera submodule to `v2.0.13` (#3316) - Added contributor list (#3317) - Added files for demo mode (#3315) From f6fd351d38cbcd2123f4232859fe73f945e6f68d Mon Sep 17 00:00:00 2001 From: CaCO3 Date: Sat, 12 Oct 2024 23:39:32 +0200 Subject: [PATCH 5/7] . --- Changelog.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Changelog.md b/Changelog.md index 9b48dfb21..f0efa18cb 100644 --- a/Changelog.md +++ b/Changelog.md @@ -13,6 +13,8 @@ Only changes since RC4 are listed: - `value` has now only set the `State Class` to `total_increasing` if `Allow Negative Rates` is NOT set. Else it uses `measurement` as it could go down. Before it was always set to `total_increasing`. - The `rate_per_time_unit` topic of an **Energy** meter needs a `Device Class`=`power`. For `gas` and `water` it should be `volume_flow_rate`. Before the `Device Class` was always set to `""`. + **:warning: Please check your Homeassistant instance to make sure it is handled correctly!** + #### Bug Fixes Only changes since RC3 are listed: - None From e8886f3c22b888375b7b12d6688a6fa6f8e084ed Mon Sep 17 00:00:00 2001 From: CaCO3 Date: Sun, 13 Oct 2024 15:14:06 +0200 Subject: [PATCH 6/7] fix rate_device_class --- code/components/jomjol_mqtt/server_mqtt.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/components/jomjol_mqtt/server_mqtt.cpp b/code/components/jomjol_mqtt/server_mqtt.cpp index 728689832..33c823f66 100644 --- a/code/components/jomjol_mqtt/server_mqtt.cpp +++ b/code/components/jomjol_mqtt/server_mqtt.cpp @@ -193,7 +193,7 @@ bool MQTThomeassistantDiscovery(int qos) { /* Energy meters need a different Device Class, see https://github.com/jomjol/AI-on-the-edge-device/issues/3333 */ std::string rate_device_class = "volume_flow_rate"; if (meterType == "energy") { - value_state_class = "power"; + rate_device_class = "power"; } // Group | Field | User Friendly Name | Icon | Unit | Device Class | State Class | Entity Category From eb31d8f0c8bc7c011a2c9aa323910424a6f35155 Mon Sep 17 00:00:00 2001 From: CaCO3 Date: Sun, 13 Oct 2024 23:03:43 +0200 Subject: [PATCH 7/7] Update Changelog.md --- Changelog.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Changelog.md b/Changelog.md index f0efa18cb..150001c6a 100644 --- a/Changelog.md +++ b/Changelog.md @@ -8,10 +8,10 @@ Please check the [issues](https://github.com/jomjol/AI-on-the-edge-device/issues #### Core Changes Only changes since RC4 are listed: -- Updated the Homeasistant Discovery topics (#3332) - - `raw` has now set the `State Class` to `measurement`. Before the `State Class` was always set to `""`. - - `value` has now only set the `State Class` to `total_increasing` if `Allow Negative Rates` is NOT set. Else it uses `measurement` as it could go down. Before it was always set to `total_increasing`. - - The `rate_per_time_unit` topic of an **Energy** meter needs a `Device Class`=`power`. For `gas` and `water` it should be `volume_flow_rate`. Before the `Device Class` was always set to `""`. +- Updated the Homeassistant Discovery topics (#3332): + - `raw` has now set the `State Class` to `measurement`. Before it was always set to `""`. + - `value` has now only set the `State Class` to `total_increasing` if the parameter `Allow Negative Rates` is **not** set. Else it uses `measurement` since the rate could also be negative. Before it was always set to `total_increasing`. + - The `rate_per_time_unit` topic of an **Energy** meter needs a `Device Class`=`power`. For `gas` and `water` it should be `volume_flow_rate`. Before it was always set to `""`. **:warning: Please check your Homeassistant instance to make sure it is handled correctly!**