SSE Stream and Event Updates

Hello,

I have a great new experience I’m working on utilizing the SSE Stream and it’s awesome. My question is we also use the event engine provided by Losant to keep track of devices in an Alert state.

An example would be a temperature threshold and a device running too hot. This triggers an Event to log the alert. We pulls these Alerts/Events to the main List dashboard for all devices then if a device is in the list of alerts we flag it red.

When clicking on a device to view, that brings the user to the devices dashboard page (custom HTML) using the SSE Stream. I love the real time data, but how do I update the pages Alert notifications since they are not on the MQTT stream coming from the device state?

Continuing the example, I click the device that’s running hot to monitor it. The device returns to normal temperatures while I’m viewing the page, but there is a red explanation of the alert (“Alert - Break Room Stainless Fridge is above your high threshold of 40°F .”)

The Event/Alert is not part of the SSE, so how do I get updated information from the Events associated with that device in the background to seamlessly update the page that the alert has been lifted?

Obviously this could go the other direction too with the device entering an Alert state and the dashboard page needing to be updated with the Alert message.

I’m open to any ideas. Thanks!

1 Like

@Jonathan_Betke,

This is a great question and thanks for all the details!

When you’re configuring the Endpoint Reply, you can select a stream source:

Here, you’ll want to use a custom topic. Like /event/alerts:

You can even go further, and set up some pretty flexible experience user specific alerting with /events/{{experience.user.id}}/alerts.

Then, in another workflow, you can use the Timer Node, the Event: Get Node, and the MQTT Node to publish messages to your custom topic. Every time you publish, it will send a message to your SSE stream.

Let me know if you have any questions. Happy to explain further.

2 Likes