I’m building a monitoring app with Dash for the observatory I’m working at.
An essential component of this monitoring is to send alarms if some parameters are not ok with what they should be. For this, I’m using a dcc.Interval to do regular checks and, if not okay, an alarm is send via our radio system through an external python script.
The issue I’m having is that if several people have the web interface open on their computer, each of them is going to send the alarm, which is a bit overwhelming when the radio get 5 alarms in the span of 30 seconds…
Would there be a way to prevent an interval to start if it’s already started in another browser (another computer) ? Or are there other possibilities to do regular checks inside a dash application ?
Simple code snippet (in case I’m doing something the wrong way) :
You could use an id for the alarm and verify if it needs to send it again, just update a small db with the id of the alarm and whether or not it was triggered. If so, ignore the duplicates.
If I understand correctly how dash works, when starting the server, it will get “GET” or “POST” requests from the client started in a browser. Is there a way to have the server to send a notification to all connected clients ?
For example, the user would have the possibility to click a button to turn ON/OFF the alarm system. Would it be possible, when this action is made, to notify the other clients that the alarm state has been changed ?
There could be a file or DB containing the alarm state that is checked to display the alarm state on your client, but then, if this file is read at a certain interval, there could be time that you leave your monitoring thinking the alarm is ON (someone turned OFF the alarm but the state file hasn’t been checked yet by your client). I don’t know if this is clear enough…
It is related to the same application but maybe it should be a different topic, sorry if that’s the case.
You are looking into the realm of websockets, which is supported very soon natively by Dash. Essentially, it allows the server to push data to the client whenever it wants to.
That’s exactly what I’m looking for, thanks for the quick answer. Is there a timeline on this ? I will work with some status files to read as a temporary solution.