Notification of new alarms

I would like my Java app to be “notified” about new alarms.

Introduction to events and alarms mentions how non-protocol integrations can be notified of new alarms.

What is the recommended approach for protocol integrations?

Should I poll API Gateway’s /api/rest/v1/alarms?

Or maybe could I receive notifications about new alarms using the WebSocket API?

I believe the WebSocket API was developed for exactly this purpose. I guess a polling scheme on the Rest API could work but the WebSocket API seems more to the task.

I made a wrong reply. The WebSocket API is only for events, not for alarms.

To poll API Gateway’s /api/rest/v1/alarms must be the better answer.

How can I learn what event type should I subscribe to get such notifications?

I tried to subscribe to everything hoping that I will be able to figure the event type from messages, but I can’t. After generating a user-defined test event, I don’t see anything immediately in the WebSocket messages. Maybe there is a delay and actually I am getting the notification.

I just see a bunch of uuids.

I tried to call GetEvent from AlarmService, with an iD of those events, to maybe get some more information about the event that way, but I get a 500 status response, saying that reading event failed.

{“events”:[{“specversion”:“1.0”,“type”:“c93e7128-bd54-43aa-9fb2-971e7926d14b”,“source”:“cameras/3730ee3a-0aba-4975-9ca7-b09a2f1b1249”,“id”:“10b03d17-1c86-4119-9aac-8475e9fac195”,“time”:“2024-06-10T13:13:04.9635185Z”,“stategroupid”:“60217956-bea0-4c7d-add5-6485c2176ffd”}]}

{“events”:[{“specversion”:“1.0”,“type”:“7a60a969-e2b9-4f47-84e7-a2f6d07c56fd”,“source”:“cameras/3730ee3a-0aba-4975-9ca7-b09a2f1b1249”,“id”:“6e347477-bd5b-41cf-9120-416c958e3e28”,“time”:“2024-06-10T13:13:07.97734Z”,“stategroupid”:“60217956-bea0-4c7d-add5-6485c2176ffd”}]}

{“events”:[{“specversion”:“1.0”,“type”:“a334af1c-4b4b-4957-9e5f-ab8ca07feab6”,“source”:“cameras/3730ee3a-0aba-4975-9ca7-b09a2f1b1249”,“id”:“8203b5b2-b3a4-4980-89a4-8d7b3c9054ab”,“time”:“2024-06-10T13:09:00.719909Z”,“stategroupid”:“53b40c77-cf48-42a2-a432-db65ae3afc7a”}]}

{“events”:[{“specversion”:“1.0”,“type”:“dd3e6464-7dc0-405a-a92f-6150587563e8”,“source”:“cameras/3730ee3a-0aba-4975-9ca7-b09a2f1b1249”,“id”:“33b9c16b-9a70-4185-aecc-a8c2b5ade6b4”,“time”:“2024-06-10T13:09:03.9184447Z”,“stategroupid”:“53b40c77-cf48-42a2-a432-db65ae3afc7a”}]}

{“events”:[{“specversion”:“1.0”,“type”:“c93e7128-bd54-43aa-9fb2-971e7926d14b”,“source”:“cameras/3730ee3a-0aba-4975-9ca7-b09a2f1b1249”,“id”:“8c5550ac-5c4e-428d-947c-06d4bc6a714f”,“time”:“2024-06-10T13:13:41.1706452Z”,“stategroupid”:“60217956-bea0-4c7d-add5-6485c2176ffd”}]}

{“events”:[{“specversion”:“1.0”,“type”:“7a60a969-e2b9-4f47-84e7-a2f6d07c56fd”,“source”:“cameras/3730ee3a-0aba-4975-9ca7-b09a2f1b1249”,“id”:“d8a769ee-9c3c-4f73-bdb7-293fce8deff7”,“time”:“2024-06-10T13:13:43.1857669Z”,“stategroupid”:“60217956-bea0-4c7d-add5-6485c2176ffd”}]}

{“events”:[{“specversion”:“1.0”,“type”:“6f55a7a7-d21c-4629-ac18-af1975e395a2”,“source”:“cameras/3730ee3a-0aba-4975-9ca7-b09a2f1b1249”,“id”:“add9e3a1-c2c5-46ed-b1e5-73e6d1017e90”,“time”:“2024-06-10T13:09:12.859Z”,“stategroupid”:“720ef62a-78be-418a-8e4c-ee04ffca6429”}]}

{“events”:[{“specversion”:“1.0”,“type”:“79a94f89-92de-4fca-8a43-5561d407423d”,“source”:“cameras/3730ee3a-0aba-4975-9ca7-b09a2f1b1249”,“id”:“20cadbd3-77ff-4805-80f3-0fa695c710ac”,“time”:“2024-06-10T13:09:15.8615257Z”,“stategroupid”:“15f76bad-f660-448f-9e1c-0539d3f54f71”}]}

Regarding event types; these can be looked up in the config API as illustrated in the EventsAndStateWebSocketApiPython sample.

E.g

  • /api/rest/v1/eventTypes/{event_type_id} for event types
  • /api/rest/v1/stateGroups/{state_group_id} for state groups
  • /api/rest/v1/{source} for the source (this will be prefixed with the resource type, e.g. cameras)

I made a wrong reply. The WebSocket API is only for events, not for alarms.

To poll API Gateway’s /api/rest/v1/alarms must be the better answer.

On the trouble you saw on the Alarm Service I recommend that you start by exploring the Alarm List sample. It is c# but pure protocol so it should be transferable to other languages and environments. For a start it can maybe show you that your setup works.

https://doc.developer.milestonesys.com/html/index.html?base=samples/protocolsamples/alarmlist/readme.html&tree=tree_3.html