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

Reduce `AlarmDevice.update()` complexity by removing unneeded filtering #98

Closed palazzem closed 10 months ago

palazzem commented 10 months ago

Is your feature request related to a problem? Please describe.

AlarmDevice.update() method relies on the underlying ElmoClient to query sectors and inputs. After the data is retrieved, the raw query is filtered to identify activated/deactivated sectors, and inputs that are triggered or in wait status:

https://github.com/palazzem/econnect-python/blob/42026cd3aae566c5ea126492548516a694c16cc2/src/elmo/devices.py#L107-L111

Describe the solution you'd like

This approach introduces an utility function, has reduced readability and is not robust in terms of method responsibilities. We should simplify this code by storing sectors/inputs raw responses, and let the HA integration identify sector by sector if it's armed or not (same applies for inputs).

Describe alternatives you've considered

Keeping these filters, but I think it increases the complexity for no obvious benefits.

Additional context

n/a

palazzem commented 10 months ago

Closed with #113