Skip to content

Commit

Permalink
Fix problem with partition_data not updating.
Browse files Browse the repository at this point in the history
  • Loading branch information
RenierM26 committed May 7, 2022
1 parent 6f9fbc1 commit 3ed2e0c
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 9 deletions.
10 changes: 5 additions & 5 deletions custom_components/ids_hyyp/alarm_control_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,11 @@ def __init__(
) -> None:
"""Initialize the sensor."""
super().__init__(coordinator, site_id, partition_id)
self._attr_name = self._partition_data["name"]
self._attr_name = self.partition_data["name"]
self._arm_code = arm_code
self._attr_unique_id = f"{self._site_id}_{partition_id}"
self._attr_code_arm_required = bool(arm_code)
self._arm_home_profile_id = list(self._partition_data["stayProfiles"])[
self._arm_home_profile_id = list(self.partition_data["stayProfiles"])[
0
] # Supports multiple stay profiles. Assume first is arm home.

Expand All @@ -80,11 +80,11 @@ def available(self) -> bool:
def state(self) -> StateType:
"""Update alarm state."""

if self._partition_data["alarm"]:
if self.partition_data["alarm"]:
return STATE_ALARM_TRIGGERED

if self._partition_data["armed"]:
if self._partition_data["stayArmed"]:
if self.partition_data["armed"]:
if self.partition_data["stayArmed"]:
return STATE_ALARM_ARMED_HOME

return STATE_ALARM_ARMED_AWAY
Expand Down
6 changes: 5 additions & 1 deletion custom_components/ids_hyyp/entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,8 @@ def __init__(
"""Initialize the entity."""
super().__init__(coordinator, site_id)
self._partition_id = partition_id
self._partition_data = self.data["partitions"][partition_id]

@property
def partition_data(self) -> Any:
"""Return partition coordinator data for this entity."""
return self.coordinator.data[self._site_id]["partitions"][self._partition_id]
2 changes: 1 addition & 1 deletion custom_components/ids_hyyp/manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"domain": "ids_hyyp",
"name": "IDS Hyyp(Beta)",
"version": "0.0.0.6",
"version": "0.0.0.7",
"documentation": "https://www.home-assistant.io/integrations/idshyyp",
"codeowners": ["@RenierM26"],
"requirements": ["pyhyypapi==0.0.0.5"],
Expand Down
4 changes: 2 additions & 2 deletions custom_components/ids_hyyp/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def __init__(
super().__init__(coordinator, site_id, partition_id)
self._bypass_code = bypass_code
self._zone_id = zone_id
self._attr_name = f"{self._partition_data['zones'][zone_id]['name'].title()}"
self._attr_name = f"{self.partition_data['zones'][zone_id]['name'].title()}"
self._attr_unique_id = f"{self._site_id}_{partition_id}_{zone_id}"

@property
Expand All @@ -74,7 +74,7 @@ def available(self) -> bool:
@property
def is_on(self) -> bool:
"""Return the state of the switch."""
return not self._partition_data["zones"][self._zone_id]["bypassed"]
return not self.partition_data["zones"][self._zone_id]["bypassed"]

async def async_turn_on(self, **kwargs: Any) -> None:
"""Turn the switch entity on."""
Expand Down

0 comments on commit 3ed2e0c

Please sign in to comment.