From e1379fa131e326843594c005508db053b188d9ac Mon Sep 17 00:00:00 2001 From: Ing-Dom Date: Fri, 6 Mar 2026 20:08:07 +0100 Subject: [PATCH 1/4] add valueCompareTime, a function that sends a group object only when it changed or has not been sent for some time --- src/knx/group_object.cpp | 11 +++++++++++ src/knx/group_object.h | 15 +++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/src/knx/group_object.cpp b/src/knx/group_object.cpp index 7f5247df..7e9289d2 100644 --- a/src/knx/group_object.cpp +++ b/src/knx/group_object.cpp @@ -349,4 +349,15 @@ bool GroupObject::valueCompare(const KNXValue& value, const Dpt& type) return true; } return false; +} + +bool GroupObject::valueCompareTime(const KNXValue& value, const Dpt& type, uint32_t& lastTime, const uint32_t time) +{ + if (valueNoSendCompare(value, type)) + { + objectWritten(); + return true; + } + else if((millis() - lastTime >= time) + return false; } \ No newline at end of file diff --git a/src/knx/group_object.h b/src/knx/group_object.h index e64c86a9..cde901dc 100644 --- a/src/knx/group_object.h +++ b/src/knx/group_object.h @@ -203,6 +203,21 @@ class GroupObject */ bool valueCompare(const KNXValue& value, const Dpt& type); + + /** + * Check if the value (after conversion to dpt) will differ from current value of the group object and send only when the value differs or the time since last sending exceeds a threshold. + * Use this method only, when the value should not be sent if it was not changed, otherwise value(const KNXValue&, const Dpt&) will do the same (without overhead for comparing) + * @param value the value the group object is set to + * @param type the datapoint type used for the conversion. + * @param lastTime the variable where the last sending time of this KO can be stored, will be passed as reference + * @param time the threshold in milliseconds used to calculate if group object is sent regardless if the value differs + * + * The parameters must fit the group object. Otherwise it will stay unchanged. + * + * @returns true if the value of the group object has changed, false if conversion results in same value as stored in group object or failed. + */ + bool valueCompareTime(const KNXValue& value, const Dpt& type, uint32_t& lastTime, const uint32_t time) + /** * set the current value of the group object and show success. * @param value the value the group object is set to From 4c037b3007ae7089967ac86d795834d7c949b67b Mon Sep 17 00:00:00 2001 From: Ing-Dom Date: Fri, 6 Mar 2026 20:36:41 +0100 Subject: [PATCH 2/4] fix incomplete commit --- src/knx/group_object.cpp | 6 +++++- src/knx/group_object.h | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/knx/group_object.cpp b/src/knx/group_object.cpp index 7e9289d2..94804656 100644 --- a/src/knx/group_object.cpp +++ b/src/knx/group_object.cpp @@ -358,6 +358,10 @@ bool GroupObject::valueCompareTime(const KNXValue& value, const Dpt& type, uint3 objectWritten(); return true; } - else if((millis() - lastTime >= time) + else if(millis() - lastTime >= time) + { + objectWritten(); + return true; + } return false; } \ No newline at end of file diff --git a/src/knx/group_object.h b/src/knx/group_object.h index cde901dc..3ffeb857 100644 --- a/src/knx/group_object.h +++ b/src/knx/group_object.h @@ -214,9 +214,9 @@ class GroupObject * * The parameters must fit the group object. Otherwise it will stay unchanged. * - * @returns true if the value of the group object has changed, false if conversion results in same value as stored in group object or failed. + * @returns true if the value of the group object has been sent, false if not or conversion failed. */ - bool valueCompareTime(const KNXValue& value, const Dpt& type, uint32_t& lastTime, const uint32_t time) + bool valueCompareTime(const KNXValue& value, const Dpt& type, uint32_t& lastTime, const uint32_t time); /** * set the current value of the group object and show success. From 346f57a8fd7e1148dd7b1a1a25e266bc620ba0cf Mon Sep 17 00:00:00 2001 From: Ing-Dom Date: Sat, 7 Mar 2026 08:04:55 +0100 Subject: [PATCH 3/4] update lastTime --- src/knx/group_object.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/knx/group_object.cpp b/src/knx/group_object.cpp index 94804656..fc2ae427 100644 --- a/src/knx/group_object.cpp +++ b/src/knx/group_object.cpp @@ -356,11 +356,13 @@ bool GroupObject::valueCompareTime(const KNXValue& value, const Dpt& type, uint3 if (valueNoSendCompare(value, type)) { objectWritten(); + lastTime = millis(); return true; } else if(millis() - lastTime >= time) { objectWritten(); + lastTime = millis(); return true; } return false; From 95ba5fc1fd654e2213deef41304f7fb6dc54af75 Mon Sep 17 00:00:00 2001 From: Ing-Dom Date: Fri, 20 Mar 2026 21:30:30 +0100 Subject: [PATCH 4/4] add Changelog --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index cab83a4b..4e5e7c35 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,7 @@ See the examples for basic usage options - change default PID_MAX_APDU_LENGTH_ROUTER from 220 to 254 - fix broken ConfigReq Responses - fix programming application when FlashTablesInvalid for 0x091A +- add GroupObject::valueCompareTime() to send a GroupObject only when value changed or after some time without sending ### v2.3.1 - 2026-03-04