Skip to content

Commit 70c6fac

Browse files
kingy444bdraco
andauthored
Move hunterdouglas_powerview data class to upstream library (home-assistant#156228)
Co-authored-by: J. Nick Koston <[email protected]>
1 parent e19d725 commit 70c6fac

File tree

6 files changed

+7
-97
lines changed

6 files changed

+7
-97
lines changed

homeassistant/components/hunterdouglas_powerview/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from typing import TYPE_CHECKING
55

66
from aiopvapi.resources.model import PowerviewData
7+
from aiopvapi.resources.shade_data import PowerviewShadeData
78
from aiopvapi.rooms import Rooms
89
from aiopvapi.scenes import Scenes
910
from aiopvapi.shades import Shades
@@ -16,7 +17,6 @@
1617
from .const import DOMAIN, HUB_EXCEPTIONS, MANUFACTURER
1718
from .coordinator import PowerviewShadeUpdateCoordinator
1819
from .model import PowerviewConfigEntry, PowerviewEntryData
19-
from .shade_data import PowerviewShadeData
2020
from .util import async_connect_hub
2121

2222
PARALLEL_UPDATES = 1

homeassistant/components/hunterdouglas_powerview/coordinator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@
88

99
from aiopvapi.helpers.aiorequest import PvApiMaintenance
1010
from aiopvapi.hub import Hub
11+
from aiopvapi.resources.shade_data import PowerviewShadeData
1112
from aiopvapi.shades import Shades
1213

1314
from homeassistant.config_entries import ConfigEntry
1415
from homeassistant.core import HomeAssistant
1516
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed
1617

1718
from .const import HUB_EXCEPTIONS
18-
from .shade_data import PowerviewShadeData
1919

2020
_LOGGER = logging.getLogger(__name__)
2121

homeassistant/components/hunterdouglas_powerview/cover.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -208,13 +208,13 @@ def _get_shade_move(self, target_hass_position: int) -> ShadePosition:
208208
async def _async_execute_move(self, move: ShadePosition) -> None:
209209
"""Execute a move that can affect multiple positions."""
210210
_LOGGER.debug("Move request %s: %s", self.name, move)
211+
# Store the requested positions so subsequent move
212+
# requests contain the secondary shade positions
213+
self.data.update_shade_position(self._shade.id, move)
211214
async with self.coordinator.radio_operation_lock:
212215
response = await self._shade.move(move)
213216
_LOGGER.debug("Move response %s: %s", self.name, response)
214217

215-
# Process the response from the hub (including new positions)
216-
self.data.update_shade_position(self._shade.id, response)
217-
218218
async def _async_set_cover_position(self, target_hass_position: int) -> None:
219219
"""Move the shade to a position."""
220220
target_hass_position = self._clamp_cover_limit(target_hass_position)

homeassistant/components/hunterdouglas_powerview/entity.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import logging
44

55
from aiopvapi.resources.shade import BaseShade, ShadePosition
6+
from aiopvapi.resources.shade_data import PowerviewShadeData
67

78
from homeassistant.helpers import device_registry as dr
89
from homeassistant.helpers.device_registry import DeviceInfo
@@ -11,7 +12,6 @@
1112
from .const import DOMAIN, MANUFACTURER
1213
from .coordinator import PowerviewShadeUpdateCoordinator
1314
from .model import PowerviewDeviceInfo
14-
from .shade_data import PowerviewShadeData
1515

1616
_LOGGER = logging.getLogger(__name__)
1717

homeassistant/components/hunterdouglas_powerview/shade_data.py

Lines changed: 0 additions & 80 deletions
This file was deleted.

homeassistant/components/hunterdouglas_powerview/util.py

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,15 @@
22

33
from __future__ import annotations
44

5-
from collections.abc import Iterable
6-
from typing import Any
7-
85
from aiopvapi.helpers.aiorequest import AioRequest
9-
from aiopvapi.helpers.constants import ATTR_ID
106
from aiopvapi.hub import Hub
117

12-
from homeassistant.core import HomeAssistant, callback
8+
from homeassistant.core import HomeAssistant
139
from homeassistant.helpers.aiohttp_client import async_get_clientsession
1410

1511
from .model import PowerviewAPI, PowerviewDeviceInfo
1612

1713

18-
@callback
19-
def async_map_data_by_id(data: Iterable[dict[str | int, Any]]):
20-
"""Return a dict with the key being the id for a list of entries."""
21-
return {entry[ATTR_ID]: entry for entry in data}
22-
23-
2414
async def async_connect_hub(
2515
hass: HomeAssistant, address: str, api_version: int | None = None
2616
) -> PowerviewAPI:

0 commit comments

Comments
 (0)