Listening for Changes
The Volue Data & Forecasts API supports listening for changes to curves. An event listener behaves like an infinite iterator, returning change events as they happen.
Setting up a listener
Section titled “Setting up a listener”Find a list of curves (or curve IDs) and pass them to session.events().
Two optional arguments are available:
start_time— Start listening from this time point. Useful for catching up on events that occurred while disconnected. When reconnecting, pass the timestamp of the last processed event to avoid missing updates. Note that this recovers only a few minutes of history, no more.timeout— Number of seconds to wait for the next event. If no event arrives within this period, anEventTimeoutobject is returned and listening continues. The connection remains open and active.
When a curve is updated, the iterator yields a CurveEvent object.
If timeout is specified and expires, an EventTimeout object is returned.
>>> curves = session.search(category='WND', area=['EE', 'LT'], frequency='H')>>> events = session.events(curves, timeout=3600)>>> for e in events:... print(e)See the listening for changes example for a complete script that appends new data to a CSV file on each event.
Was this page helpful?Thanks for your feedback!