palazzem / econnect-python

API adapter used to control programmatically an Elmo alarm system
BSD 3-Clause "New" or "Revised" License
8 stars 5 forks source link

Implement long-polling to retrieve state updates #67

Closed palazzem closed 3 years ago

palazzem commented 3 years ago

Overview

Econnect API implements a long-polling in /api/updates endpoint. This change leverages this API to understand when the state is updated, so that it can trigger a client.check() call to get the latest. It prevents making a random polling (e.g. every 5 seconds), while triggering an update only when something changes.

At the time of writing, this API blocks the thread for 15 seconds, or unless something changes. To make it work, the client has to store inputs and areas IDs to get an update. This is not ideal but that's what the API offers.