Skip to content

Commit

Permalink
fix: #283 fix error on empty cross unit groups
Browse files Browse the repository at this point in the history
  • Loading branch information
fwmarcel committed Feb 10, 2025
1 parent 4721369 commit 7e6fe13
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
6 changes: 3 additions & 3 deletions custom_components/divera/divera.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,8 +320,8 @@ def get_last_alarm_attributes(self) -> dict:
alarm = self.__data["data"]["alarm"]["items"].get(str(last_alarm_id), {})

cross_unit_meta = alarm.get("cross_unit_meta", {})
cross_unit_groups = cross_unit_meta.get("groups", [])
cross_unit_clusters = cross_unit_meta.get("clusters", [])
cross_unit_groups = cross_unit_meta.get("groups", {})
cross_unit_clusters = cross_unit_meta.get("clusters", {})

groups = []

Expand All @@ -330,7 +330,7 @@ def get_last_alarm_attributes(self) -> dict:
if group_name is not None:
groups.append(group_name)
else:
cug = cross_unit_groups.get(str(group_id))
cug = cross_unit_groups.get(str(group_id), {})
if cug:
cluster_id = cug.get("cluster_id")
cluster_name = cross_unit_clusters.get(str(cluster_id), {}).get(
Expand Down
5 changes: 3 additions & 2 deletions custom_components/divera/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,11 @@ async def async_setup_entry(
},
icon="mdi:fire-truck",
value_fn=lambda divera, vid=vehicle_id: divera.get_vehicle_state(
vid # noqa: B023
),
vid
), # noqa: B023
attribute_fn=lambda divera,
vid=vehicle_id: divera.get_vehicle_attributes(vid), # noqa: B023
entity_registry_enabled_default=False,
),
)
entities.append(vehicle_entity)
Expand Down

0 comments on commit 7e6fe13

Please sign in to comment.