Skip to content

Commit

Permalink
feat: allow missing sections by faking empty AmcData
Browse files Browse the repository at this point in the history
  • Loading branch information
vermut committed Jun 3, 2024
1 parent 03e32dc commit bc8ff8a
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions custom_components/amc_alarm/amc_alarm_api/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,8 +239,11 @@ def raw_states(self) -> dict[str, AmcCentralResponse]:

def _get_section(self, central_id, section_index) -> AmcData | AmcNotification:
central = self._raw_states[central_id]
zones = next(x for x in central.data if x.index == section_index)
return zones
try:
section = next(x for x in central.data if x.index == section_index)
return section
except StopIteration:
return AmcData(index=0, list=[], name="_none")

def groups(self, central_id: str) -> AmcData:
return self._get_section(central_id, CentralDataSections.GROUPS)
Expand Down

0 comments on commit bc8ff8a

Please sign in to comment.