The has_motion_event function incorrectly yields false positives because it only checks for the presence of topic strings and property names, completely ignoring the actual logical state (true/false) of the event.
In the current implementation, it uses simple strstr checks:
if (strstr(response, "CellMotionDetector") ||
strstr(response, "PeopleDetector") ||
strstr(response, "IsMotion") ||
strstr(response, "IsPeople")) {
return true;
}
Standard ONVIF WS-BaseNotification payloads include these topic names and property attributes in every single message, regardless of whether the state is transitionary or idle. For instance, when a camera reports that motion has stopped, or sends a status update, it transmits a payload containing Value="false" or Data=0, but still explicitly names the property:
<tt:SimpleItem Name="IsMotion" Value="false"/>
Because strstr(response, "IsMotion") evaluates to true here, the function returns true, causing the NVR to flag an active motion event when the scene is actually quiet.
The parsing logic needs to look for the actual assertion state. A quick substring approach could verify if Value="true" or Value="1" is tied to those attributes, though a minimal XML parsing check would be more robust to prevent matching standard metadata headers.
The
has_motion_eventfunction incorrectly yields false positives because it only checks for the presence of topic strings and property names, completely ignoring the actual logical state (true/false) of the event.In the current implementation, it uses simple strstr checks:
Standard ONVIF WS-BaseNotification payloads include these topic names and property attributes in every single message, regardless of whether the state is transitionary or idle. For instance, when a camera reports that motion has stopped, or sends a status update, it transmits a payload containing
Value="false"orData=0, but still explicitly names the property:Because
strstr(response, "IsMotion")evaluates to true here, the function returns true, causing the NVR to flag an active motion event when the scene is actually quiet.The parsing logic needs to look for the actual assertion state. A quick substring approach could verify if
Value="true"orValue="1"is tied to those attributes, though a minimal XML parsing check would be more robust to prevent matching standard metadata headers.