From 2f951ca684944ea41908902cf730794ec2e8559b Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Mon, 31 Aug 2026 12:18:23 +0200 Subject: [PATCH] aqhome-cgi: optionally check for last change. --- apps/aqhome-cgi/modules/devices/mdevices_page2.c | 6 +++++- apps/aqhome-cgi/modules/devices/mdevices_pagectx.c | 10 ++++++---- apps/aqhome-cgi/modules/devices/mdevices_pagectx.h | 2 +- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/apps/aqhome-cgi/modules/devices/mdevices_page2.c b/apps/aqhome-cgi/modules/devices/mdevices_page2.c index 4f4d0a71..e9f3646f 100644 --- a/apps/aqhome-cgi/modules/devices/mdevices_page2.c +++ b/apps/aqhome-cgi/modules/devices/mdevices_page2.c @@ -511,8 +511,10 @@ void _writePageDataSet(AQH_MD_PAGECTX *ctx, const char *sPageId, GWEN_XMLNODE *n const char *sVarType; const char *sModality; const char *sVarName; + const char *sLastChange; int modality; int varType; + uint64_t lastChange; AQH_MD_PAGECTX *newCtx; /* prepare new context */ @@ -520,9 +522,11 @@ void _writePageDataSet(AQH_MD_PAGECTX *ctx, const char *sPageId, GWEN_XMLNODE *n sRoom=GWEN_XMLNode_GetProperty(nElement, "room", NULL); sModality=GWEN_XMLNode_GetProperty(nElement, "modality", NULL); sVarName=GWEN_XMLNode_GetProperty(nElement, "varname", NULL); + sLastChange=GWEN_XMLNode_GetProperty(nElement, "lastChange", NULL); modality=sModality?AQH_ValueModality_fromString(sModality):AQH_ValueModality_Unknown; varType=sVarType?AQH_ValueType_fromString(sVarType):AQH_ValueType_Sensor; - newCtx=AQH_MDPageCtx_CopyWithMatchingVars(ctx, varType, sRoom, modality, sVarName); + lastChange=sLastChange?AQH_ParseTime(sLastChange):0; + newCtx=AQH_MDPageCtx_CopyWithMatchingVars(ctx, varType, sRoom, modality, sVarName, lastChange); /* enter context */ _writePageChildElements(newCtx, sPageId, nElement, dbuf); /* free new context */ diff --git a/apps/aqhome-cgi/modules/devices/mdevices_pagectx.c b/apps/aqhome-cgi/modules/devices/mdevices_pagectx.c index 273395a0..e37187d3 100644 --- a/apps/aqhome-cgi/modules/devices/mdevices_pagectx.c +++ b/apps/aqhome-cgi/modules/devices/mdevices_pagectx.c @@ -33,7 +33,7 @@ GWEN_TREE2_FUNCTIONS(AQH_MD_PAGECTX, AQH_MDPageCtx); * ------------------------------------------------------------------------------------------------ */ -static int _valueMatches(const AQH_VALUE *value, int varType, const char *room, int modality, const char *vname); +static int _valueMatches(const AQH_VALUE *value, int varType, const char *room, int modality, const char *vname, uint64_t lastChange); @@ -71,7 +71,7 @@ void AQH_MDPageCtx_free(AQH_MD_PAGECTX *ctx) AQH_MD_PAGECTX *AQH_MDPageCtx_CopyWithMatchingVars(const AQH_MD_PAGECTX *octx, - int varType, const char *room, int modality, const char *vname) + int varType, const char *room, int modality, const char *vname, uint64_t lastChange) { AQH_MD_PAGECTX *ctx=NULL; @@ -92,7 +92,7 @@ AQH_MD_PAGECTX *AQH_MDPageCtx_CopyWithMatchingVars(const AQH_MD_PAGECTX *octx, valueList=AQH_Value_List_new(); vSrc=AQH_Value_List_First(octx->valueList); while(vSrc) { - if (_valueMatches(vSrc, varType, room, modality, vname)) { + if (_valueMatches(vSrc, varType, room, modality, vname, lastChange)) { AQH_VALUE *vDest; DBG_ERROR(NULL, "+ %s", AQH_Value_GetNameForSystem(vSrc)); @@ -115,7 +115,7 @@ AQH_MD_PAGECTX *AQH_MDPageCtx_CopyWithMatchingVars(const AQH_MD_PAGECTX *octx, -int _valueMatches(const AQH_VALUE *value, int varType, const char *room, int modality, const char *vname) +int _valueMatches(const AQH_VALUE *value, int varType, const char *room, int modality, const char *vname, uint64_t lastChange) { int matches=1; @@ -125,6 +125,8 @@ int _valueMatches(const AQH_VALUE *value, int varType, const char *room, int mod if (matches && modality && modality!=AQH_Value_GetModality(value)) matches=0; /* then slower compares */ + if (matches && lastChange && AQH_Value_GetTimestampLastChange(value)