Skip to content

Commit fe01e96

Browse files
hbludworthjoostlek
authored andcommitted
Fix Aladdin Connect state not updating (home-assistant#151652)
Co-authored-by: Joostlek <[email protected]>
1 parent 0b56ec1 commit fe01e96

File tree

7 files changed

+15
-21
lines changed

7 files changed

+15
-21
lines changed

homeassistant/components/aladdin_connect/__init__.py

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
from __future__ import annotations
44

55
from genie_partner_sdk.client import AladdinConnectClient
6-
from genie_partner_sdk.model import GarageDoor
76

87
from homeassistant.const import Platform
98
from homeassistant.core import HomeAssistant
@@ -36,22 +35,7 @@ async def async_setup_entry(
3635
api.AsyncConfigEntryAuth(aiohttp_client.async_get_clientsession(hass), session)
3736
)
3837

39-
sdk_doors = await client.get_doors()
40-
41-
# Convert SDK GarageDoor objects to integration GarageDoor objects
42-
doors = [
43-
GarageDoor(
44-
{
45-
"device_id": door.device_id,
46-
"door_number": door.door_number,
47-
"name": door.name,
48-
"status": door.status,
49-
"link_status": door.link_status,
50-
"battery_level": door.battery_level,
51-
}
52-
)
53-
for door in sdk_doors
54-
]
38+
doors = await client.get_doors()
5539

5640
entry.runtime_data = {
5741
door.unique_id: AladdinConnectCoordinator(hass, entry, client, door)

homeassistant/components/aladdin_connect/coordinator.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,10 @@ def __init__(
4141
async def _async_update_data(self) -> GarageDoor:
4242
"""Fetch data from the Aladdin Connect API."""
4343
await self.client.update_door(self.data.device_id, self.data.door_number)
44+
self.data.status = self.client.get_door_status(
45+
self.data.device_id, self.data.door_number
46+
)
47+
self.data.battery_level = self.client.get_battery_status(
48+
self.data.device_id, self.data.door_number
49+
)
4450
return self.data

homeassistant/components/aladdin_connect/cover.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,9 @@ async def async_close_cover(self, **kwargs: Any) -> None:
4949
@property
5050
def is_closed(self) -> bool | None:
5151
"""Update is closed attribute."""
52-
return self.coordinator.data.status == "closed"
52+
if (status := self.coordinator.data.status) is None:
53+
return None
54+
return status == "closed"
5355

5456
@property
5557
def is_closing(self) -> bool | None:

homeassistant/components/aladdin_connect/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@
77
"documentation": "https://www.home-assistant.io/integrations/aladdin_connect",
88
"integration_type": "hub",
99
"iot_class": "cloud_polling",
10-
"requirements": ["genie-partner-sdk==1.0.10"]
10+
"requirements": ["genie-partner-sdk==1.0.11"]
1111
}

requirements_all.txt

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

requirements_test_all.txt

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/components/aladdin_connect/test_init.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ async def test_setup_entry(hass: HomeAssistant) -> None:
3030
mock_door.status = "closed"
3131
mock_door.link_status = "connected"
3232
mock_door.battery_level = 100
33+
mock_door.unique_id = f"{mock_door.device_id}-{mock_door.door_number}"
3334

3435
mock_client = AsyncMock()
3536
mock_client.get_doors.return_value = [mock_door]
@@ -80,6 +81,7 @@ async def test_unload_entry(hass: HomeAssistant) -> None:
8081
mock_door.status = "closed"
8182
mock_door.link_status = "connected"
8283
mock_door.battery_level = 100
84+
mock_door.unique_id = f"{mock_door.device_id}-{mock_door.door_number}"
8385

8486
# Mock client
8587
mock_client = AsyncMock()

0 commit comments

Comments
 (0)