Events and State WebSocket API: Events IDs, Subscription Filters, and Events Simulation

We would like to use the Events and State WebSocket API to subscribe to some predefined events from here: https://doc.milestonesys.com/latest/en-US/standard_features/sf_mc/sf_ui/mc_eventsoverview_rulesandevents.htm

we have chosen the following events :

  • Communication Error (Device)
  • Settings Changed Error
  • Memory usage critical
  • NVIDIA memory critical
  • Used space critical
  • Free space critical
  • Retention time critical
  • Scheduled password change completed with errors

Now the subscription filter I need to send requires the events IDs so when I looked into the MIP SDK I was able to find the following events IDs

  • CommunicationError = “A334AF1C-4B4B-4957-9E5F-AB8CA07FEAB6”
  • DeviceSettingsChangedError = “87BE2A0D-C33B-4B5F-AE1F-AFA6770A2497”
  • SystemMonitorMemoryUsageCritical = “363741CF-4D7A-426D-9FE2-A201C4DB51C0”
  • SystemMonitorUsedSpaceCritical = “766CF688-F3E2-4D2F-8D08-012193783739”
  • SystemMonitorFreeSpaceCritical = “F80AF822-6A89-4C2F-AB38-B55D0D2CD13A”
  • SystemMonitorRetentionTimeCritical = “D1603FBE-4BB8-49EB-9928-0E8EB3C736CE”

However, I was not able to find the events IDs for the following :

  • NVIDIA memory critical
  • Scheduled password change completed with errors

1. Can you please provide me with IDs for those events?

In the provided example the Subscriptions Filters looked like this

subscription_filters = [

{

    "modifier": "include",

    "resourceTypes": \[ "cameras" \],

    "sourceIds": \[ "\*" \],

    "eventTypes": \[ event\_types.motion\_started, event\_types.motion\_stopped, event\_types.recording\_started, event\_types.recording\_stopped \]

}

]

2. For the given events what should the resource types be?

3. Finally is there a way to force those events to happen in Milestone? we need this to test our integration and ensure we handle those events accordingly.

Hi Osama,

Let me try answering your questions.

We try to get rid of all the hardcoded values (in the code), so there is a way to fetch all the possible event types with a REST API call from Config API.

Namely GET call to “/api/rest/v1/eventTypes” towards the API GW.

The response contains all the registered event types into the system (currently around 280 or something).

There you could search and find:

{
    "displayName": "Nvidia Memory Critical",
    "id": "cbe4e664-8ad6-404f-9ea3-63633ebb1273",
    "name": "Nvidia Memory Critical",
    "sourceArray": [
        "System",
        "RecordingServer"
    ],
},
{
    "displayName": "Scheduled password change completed with errors",
    "id": "f0c89e43-4757-423a-a9e9-2426f228a2e5",
    "name": "Scheduled password change completed with errors",
    "sourceArray": [
        "System"
    ],
},

Almost all the events you are interested in are with source “System”. For them could be used resource types “sites” or directly id of the Management Server (aka the site).

Exception is the “CommunicationError” event, where the source is actual device that has communication problems. This could be almost anything under “hardware”, like “cameras”, “microphones”, “speakers”, “metadata”, “inputs” & “outputs”. So depending on what you are interested in, you could specify one or multiple of them. Also option is and to use wildcard symbol - asterisk (“*”).

If I were you, I would probably separate to two filters - one for “system” group of events and another for device events (communication error). Ofc if you are interested in all the communication errors from all the device types and plan to use wildcard anyways, you could combine everything into a single filter with a wildcard for resource types.

As for how to “emulate” those events - well this could be tricky.

Communication error usually is easy to test with unplugging “cable” of particular camera/device (test system ofc, not doing it in production).

For system monitor events you could be creative a figure out ways to cause them (decreasing physical memory - HDD/RAM, increasing retention time, etc)

Settings changed error (incl scheduled password change) however would be challenging. I’m not sure I can come up with something.

Hi! Petar!

Regarding using the endpoint “/api/rest/v1/eventTypes” to get the mapping from GUID to a readable value. Could the guid value for a certain eventType change or is it always the same? We are thinking of creating constants like:

public const string RecordingFPSNormal = "839754e6-82af-44fc-9e2f-437413d602d6";

or should be when starting our integration call “/api/rest/v1/eventTypes” end then in runtime look up the guid for the even name “Live FPS Normal”?

Kind regards Hans Olausson

Hi Hans,

From historical point of view, we (at Milestone) are moving from strings (messages) to ids (guids). Those Ids of event types are written in the DB and as such they could be changed. But that should not be our deliberate choice. So the ids of the system event types should stay pretty much static between XPCO versions in my view.

On the other hand event type name and/or description is something that could eventually change. In the example of the previous post - “Nvidia Memory XXX” is not the best name for the event(s). It was, when it was introduced, as it was fired only on NVidia memory problem/restoration detection. But right now (if I’m not mistaken) it could be thrown for the Intel GPU memory as well. And actually it’s internal name is “GPU Memory XXX”. So at some point we could decide to finally fix that and eventually change the event name. But keeping the same Id.

In short - if I were you, I would rely more on the (fixed) ids than the names.

KR

Petar