Migrate hunterdouglas_powerview to use entry.runtime_data (#121887)
This commit is contained in:
parent
2dec7136c8
commit
62613af033
10 changed files with 46 additions and 69 deletions
|
@ -9,7 +9,6 @@ from aiopvapi.rooms import Rooms
|
||||||
from aiopvapi.scenes import Scenes
|
from aiopvapi.scenes import Scenes
|
||||||
from aiopvapi.shades import Shades
|
from aiopvapi.shades import Shades
|
||||||
|
|
||||||
from homeassistant.config_entries import ConfigEntry
|
|
||||||
from homeassistant.const import CONF_API_VERSION, CONF_HOST, Platform
|
from homeassistant.const import CONF_API_VERSION, CONF_HOST, Platform
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.exceptions import ConfigEntryNotReady
|
from homeassistant.exceptions import ConfigEntryNotReady
|
||||||
|
@ -18,7 +17,7 @@ import homeassistant.helpers.config_validation as cv
|
||||||
|
|
||||||
from .const import DOMAIN, HUB_EXCEPTIONS
|
from .const import DOMAIN, HUB_EXCEPTIONS
|
||||||
from .coordinator import PowerviewShadeUpdateCoordinator
|
from .coordinator import PowerviewShadeUpdateCoordinator
|
||||||
from .model import PowerviewDeviceInfo, PowerviewEntryData
|
from .model import PowerviewConfigEntry, PowerviewDeviceInfo, PowerviewEntryData
|
||||||
from .shade_data import PowerviewShadeData
|
from .shade_data import PowerviewShadeData
|
||||||
|
|
||||||
PARALLEL_UPDATES = 1
|
PARALLEL_UPDATES = 1
|
||||||
|
@ -36,7 +35,7 @@ PLATFORMS = [
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
async def async_setup_entry(hass: HomeAssistant, entry: PowerviewConfigEntry) -> bool:
|
||||||
"""Set up Hunter Douglas PowerView from a config entry."""
|
"""Set up Hunter Douglas PowerView from a config entry."""
|
||||||
|
|
||||||
config = entry.data
|
config = entry.data
|
||||||
|
@ -100,7 +99,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||||
# populate raw shade data into the coordinator for diagnostics
|
# populate raw shade data into the coordinator for diagnostics
|
||||||
coordinator.data.store_group_data(shade_data)
|
coordinator.data.store_group_data(shade_data)
|
||||||
|
|
||||||
hass.data.setdefault(DOMAIN, {})[entry.entry_id] = PowerviewEntryData(
|
entry.runtime_data = PowerviewEntryData(
|
||||||
api=pv_request,
|
api=pv_request,
|
||||||
room_data=room_data.processed,
|
room_data=room_data.processed,
|
||||||
scene_data=scene_data.processed,
|
scene_data=scene_data.processed,
|
||||||
|
@ -126,8 +125,6 @@ async def async_get_device_info(hub: Hub) -> PowerviewDeviceInfo:
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
async def async_unload_entry(hass: HomeAssistant, entry: PowerviewConfigEntry) -> bool:
|
||||||
"""Unload a config entry."""
|
"""Unload a config entry."""
|
||||||
if unload_ok := await hass.config_entries.async_unload_platforms(entry, PLATFORMS):
|
return await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
|
||||||
hass.data[DOMAIN].pop(entry.entry_id)
|
|
||||||
return unload_ok
|
|
||||||
|
|
|
@ -20,15 +20,13 @@ from homeassistant.components.button import (
|
||||||
ButtonEntity,
|
ButtonEntity,
|
||||||
ButtonEntityDescription,
|
ButtonEntityDescription,
|
||||||
)
|
)
|
||||||
from homeassistant.config_entries import ConfigEntry
|
|
||||||
from homeassistant.const import EntityCategory
|
from homeassistant.const import EntityCategory
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
|
|
||||||
from .const import DOMAIN
|
|
||||||
from .coordinator import PowerviewShadeUpdateCoordinator
|
from .coordinator import PowerviewShadeUpdateCoordinator
|
||||||
from .entity import ShadeEntity
|
from .entity import ShadeEntity
|
||||||
from .model import PowerviewDeviceInfo, PowerviewEntryData
|
from .model import PowerviewConfigEntry, PowerviewDeviceInfo
|
||||||
|
|
||||||
|
|
||||||
@dataclass(frozen=True)
|
@dataclass(frozen=True)
|
||||||
|
@ -75,13 +73,11 @@ BUTTONS_SHADE: Final = [
|
||||||
|
|
||||||
async def async_setup_entry(
|
async def async_setup_entry(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
entry: ConfigEntry,
|
entry: PowerviewConfigEntry,
|
||||||
async_add_entities: AddEntitiesCallback,
|
async_add_entities: AddEntitiesCallback,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Set up the hunter douglas advanced feature buttons."""
|
"""Set up the hunter douglas advanced feature buttons."""
|
||||||
|
pv_entry = entry.runtime_data
|
||||||
pv_entry: PowerviewEntryData = hass.data[DOMAIN][entry.entry_id]
|
|
||||||
|
|
||||||
entities: list[ButtonEntity] = []
|
entities: list[ButtonEntity] = []
|
||||||
for shade in pv_entry.shade_data.values():
|
for shade in pv_entry.shade_data.values():
|
||||||
room_name = getattr(pv_entry.room_data.get(shade.room_id), ATTR_NAME, "")
|
room_name = getattr(pv_entry.room_data.get(shade.room_id), ATTR_NAME, "")
|
||||||
|
|
|
@ -25,15 +25,14 @@ from homeassistant.components.cover import (
|
||||||
CoverEntity,
|
CoverEntity,
|
||||||
CoverEntityFeature,
|
CoverEntityFeature,
|
||||||
)
|
)
|
||||||
from homeassistant.config_entries import ConfigEntry
|
|
||||||
from homeassistant.core import CALLBACK_TYPE, HomeAssistant, callback
|
from homeassistant.core import CALLBACK_TYPE, HomeAssistant, callback
|
||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
from homeassistant.helpers.event import async_call_later
|
from homeassistant.helpers.event import async_call_later
|
||||||
|
|
||||||
from .const import DOMAIN, STATE_ATTRIBUTE_ROOM_NAME
|
from .const import STATE_ATTRIBUTE_ROOM_NAME
|
||||||
from .coordinator import PowerviewShadeUpdateCoordinator
|
from .coordinator import PowerviewShadeUpdateCoordinator
|
||||||
from .entity import ShadeEntity
|
from .entity import ShadeEntity
|
||||||
from .model import PowerviewDeviceInfo, PowerviewEntryData
|
from .model import PowerviewConfigEntry, PowerviewDeviceInfo
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
@ -49,12 +48,13 @@ SCAN_INTERVAL = timedelta(minutes=10)
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(
|
async def async_setup_entry(
|
||||||
hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
|
hass: HomeAssistant,
|
||||||
|
entry: PowerviewConfigEntry,
|
||||||
|
async_add_entities: AddEntitiesCallback,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Set up the hunter douglas shades."""
|
"""Set up the hunter douglas shades."""
|
||||||
|
pv_entry = entry.runtime_data
|
||||||
pv_entry: PowerviewEntryData = hass.data[DOMAIN][entry.entry_id]
|
coordinator = pv_entry.coordinator
|
||||||
coordinator: PowerviewShadeUpdateCoordinator = pv_entry.coordinator
|
|
||||||
|
|
||||||
async def _async_initial_refresh() -> None:
|
async def _async_initial_refresh() -> None:
|
||||||
"""Force position refresh shortly after adding.
|
"""Force position refresh shortly after adding.
|
||||||
|
|
|
@ -3,20 +3,18 @@
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from dataclasses import asdict
|
from dataclasses import asdict
|
||||||
import logging
|
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
import attr
|
import attr
|
||||||
|
|
||||||
from homeassistant.components.diagnostics import async_redact_data
|
from homeassistant.components.diagnostics import async_redact_data
|
||||||
from homeassistant.config_entries import ConfigEntry
|
|
||||||
from homeassistant.const import ATTR_CONFIGURATION_URL, CONF_HOST
|
from homeassistant.const import ATTR_CONFIGURATION_URL, CONF_HOST
|
||||||
from homeassistant.core import HomeAssistant, callback
|
from homeassistant.core import HomeAssistant, callback
|
||||||
from homeassistant.helpers import device_registry as dr, entity_registry as er
|
from homeassistant.helpers import device_registry as dr, entity_registry as er
|
||||||
from homeassistant.helpers.device_registry import DeviceEntry
|
from homeassistant.helpers.device_registry import DeviceEntry
|
||||||
|
|
||||||
from .const import DOMAIN, REDACT_HUB_ADDRESS, REDACT_MAC_ADDRESS, REDACT_SERIAL_NUMBER
|
from .const import REDACT_HUB_ADDRESS, REDACT_MAC_ADDRESS, REDACT_SERIAL_NUMBER
|
||||||
from .model import PowerviewEntryData
|
from .model import PowerviewConfigEntry
|
||||||
|
|
||||||
REDACT_CONFIG = {
|
REDACT_CONFIG = {
|
||||||
CONF_HOST,
|
CONF_HOST,
|
||||||
|
@ -26,11 +24,9 @@ REDACT_CONFIG = {
|
||||||
ATTR_CONFIGURATION_URL,
|
ATTR_CONFIGURATION_URL,
|
||||||
}
|
}
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
|
||||||
|
|
||||||
|
|
||||||
async def async_get_config_entry_diagnostics(
|
async def async_get_config_entry_diagnostics(
|
||||||
hass: HomeAssistant, entry: ConfigEntry
|
hass: HomeAssistant, entry: PowerviewConfigEntry
|
||||||
) -> dict[str, Any]:
|
) -> dict[str, Any]:
|
||||||
"""Return diagnostics for a config entry."""
|
"""Return diagnostics for a config entry."""
|
||||||
data = _async_get_diagnostics(hass, entry)
|
data = _async_get_diagnostics(hass, entry)
|
||||||
|
@ -47,7 +43,7 @@ async def async_get_config_entry_diagnostics(
|
||||||
|
|
||||||
|
|
||||||
async def async_get_device_diagnostics(
|
async def async_get_device_diagnostics(
|
||||||
hass: HomeAssistant, entry: ConfigEntry, device: DeviceEntry
|
hass: HomeAssistant, entry: PowerviewConfigEntry, device: DeviceEntry
|
||||||
) -> dict[str, Any]:
|
) -> dict[str, Any]:
|
||||||
"""Return diagnostics for a device entry."""
|
"""Return diagnostics for a device entry."""
|
||||||
data = _async_get_diagnostics(hass, entry)
|
data = _async_get_diagnostics(hass, entry)
|
||||||
|
@ -65,10 +61,10 @@ async def async_get_device_diagnostics(
|
||||||
@callback
|
@callback
|
||||||
def _async_get_diagnostics(
|
def _async_get_diagnostics(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
entry: ConfigEntry,
|
entry: PowerviewConfigEntry,
|
||||||
) -> dict[str, Any]:
|
) -> dict[str, Any]:
|
||||||
"""Return diagnostics for a config entry."""
|
"""Return diagnostics for a config entry."""
|
||||||
pv_entry: PowerviewEntryData = hass.data[DOMAIN][entry.entry_id]
|
pv_entry = entry.runtime_data
|
||||||
shade_data = pv_entry.coordinator.data.get_all_raw_data()
|
shade_data = pv_entry.coordinator.data.get_all_raw_data()
|
||||||
hub_info = async_redact_data(asdict(pv_entry.device_info), REDACT_CONFIG)
|
hub_info = async_redact_data(asdict(pv_entry.device_info), REDACT_CONFIG)
|
||||||
return {"hub_info": hub_info, "shade_data": shade_data}
|
return {"hub_info": hub_info, "shade_data": shade_data}
|
||||||
|
|
|
@ -9,8 +9,12 @@ from aiopvapi.resources.room import Room
|
||||||
from aiopvapi.resources.scene import Scene
|
from aiopvapi.resources.scene import Scene
|
||||||
from aiopvapi.resources.shade import BaseShade
|
from aiopvapi.resources.shade import BaseShade
|
||||||
|
|
||||||
|
from homeassistant.config_entries import ConfigEntry
|
||||||
|
|
||||||
from .coordinator import PowerviewShadeUpdateCoordinator
|
from .coordinator import PowerviewShadeUpdateCoordinator
|
||||||
|
|
||||||
|
type PowerviewConfigEntry = ConfigEntry[PowerviewEntryData]
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class PowerviewEntryData:
|
class PowerviewEntryData:
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
|
|
||||||
from collections.abc import Callable
|
from collections.abc import Callable
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
import logging
|
|
||||||
from typing import Final
|
from typing import Final
|
||||||
|
|
||||||
from aiopvapi.helpers.constants import ATTR_NAME, MOTION_VELOCITY
|
from aiopvapi.helpers.constants import ATTR_NAME, MOTION_VELOCITY
|
||||||
|
@ -13,17 +12,13 @@ from homeassistant.components.number import (
|
||||||
NumberMode,
|
NumberMode,
|
||||||
RestoreNumber,
|
RestoreNumber,
|
||||||
)
|
)
|
||||||
from homeassistant.config_entries import ConfigEntry
|
|
||||||
from homeassistant.const import EntityCategory
|
from homeassistant.const import EntityCategory
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
|
|
||||||
from .const import DOMAIN
|
|
||||||
from .coordinator import PowerviewShadeUpdateCoordinator
|
from .coordinator import PowerviewShadeUpdateCoordinator
|
||||||
from .entity import ShadeEntity
|
from .entity import ShadeEntity
|
||||||
from .model import PowerviewDeviceInfo, PowerviewEntryData
|
from .model import PowerviewConfigEntry, PowerviewDeviceInfo
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
|
||||||
|
|
||||||
|
|
||||||
@dataclass(frozen=True, kw_only=True)
|
@dataclass(frozen=True, kw_only=True)
|
||||||
|
@ -57,12 +52,12 @@ NUMBERS: Final = (
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(
|
async def async_setup_entry(
|
||||||
hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
|
hass: HomeAssistant,
|
||||||
|
entry: PowerviewConfigEntry,
|
||||||
|
async_add_entities: AddEntitiesCallback,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Set up the hunter douglas number entities."""
|
"""Set up the hunter douglas number entities."""
|
||||||
|
pv_entry = entry.runtime_data
|
||||||
pv_entry: PowerviewEntryData = hass.data[DOMAIN][entry.entry_id]
|
|
||||||
|
|
||||||
entities: list[PowerViewNumber] = []
|
entities: list[PowerViewNumber] = []
|
||||||
for shade in pv_entry.shade_data.values():
|
for shade in pv_entry.shade_data.values():
|
||||||
room_name = getattr(pv_entry.room_data.get(shade.room_id), ATTR_NAME, "")
|
room_name = getattr(pv_entry.room_data.get(shade.room_id), ATTR_NAME, "")
|
||||||
|
|
|
@ -9,14 +9,13 @@ from aiopvapi.helpers.constants import ATTR_NAME
|
||||||
from aiopvapi.resources.scene import Scene as PvScene
|
from aiopvapi.resources.scene import Scene as PvScene
|
||||||
|
|
||||||
from homeassistant.components.scene import Scene
|
from homeassistant.components.scene import Scene
|
||||||
from homeassistant.config_entries import ConfigEntry
|
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
|
|
||||||
from .const import DOMAIN, STATE_ATTRIBUTE_ROOM_NAME
|
from .const import STATE_ATTRIBUTE_ROOM_NAME
|
||||||
from .coordinator import PowerviewShadeUpdateCoordinator
|
from .coordinator import PowerviewShadeUpdateCoordinator
|
||||||
from .entity import HDEntity
|
from .entity import HDEntity
|
||||||
from .model import PowerviewDeviceInfo, PowerviewEntryData
|
from .model import PowerviewConfigEntry, PowerviewDeviceInfo
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
@ -24,12 +23,12 @@ RESYNC_DELAY = 60
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(
|
async def async_setup_entry(
|
||||||
hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
|
hass: HomeAssistant,
|
||||||
|
entry: PowerviewConfigEntry,
|
||||||
|
async_add_entities: AddEntitiesCallback,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Set up powerview scene entries."""
|
"""Set up powerview scene entries."""
|
||||||
|
pv_entry = entry.runtime_data
|
||||||
pv_entry: PowerviewEntryData = hass.data[DOMAIN][entry.entry_id]
|
|
||||||
|
|
||||||
pvscenes: list[PowerViewScene] = []
|
pvscenes: list[PowerViewScene] = []
|
||||||
for scene in pv_entry.scene_data.values():
|
for scene in pv_entry.scene_data.values():
|
||||||
room_name = getattr(pv_entry.room_data.get(scene.room_id), ATTR_NAME, "")
|
room_name = getattr(pv_entry.room_data.get(scene.room_id), ATTR_NAME, "")
|
||||||
|
|
|
@ -4,24 +4,19 @@ from __future__ import annotations
|
||||||
|
|
||||||
from collections.abc import Callable, Coroutine
|
from collections.abc import Callable, Coroutine
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
import logging
|
|
||||||
from typing import Any, Final
|
from typing import Any, Final
|
||||||
|
|
||||||
from aiopvapi.helpers.constants import ATTR_NAME, FUNCTION_SET_POWER
|
from aiopvapi.helpers.constants import ATTR_NAME, FUNCTION_SET_POWER
|
||||||
from aiopvapi.resources.shade import BaseShade
|
from aiopvapi.resources.shade import BaseShade
|
||||||
|
|
||||||
from homeassistant.components.select import SelectEntity, SelectEntityDescription
|
from homeassistant.components.select import SelectEntity, SelectEntityDescription
|
||||||
from homeassistant.config_entries import ConfigEntry
|
|
||||||
from homeassistant.const import EntityCategory
|
from homeassistant.const import EntityCategory
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
|
|
||||||
from .const import DOMAIN
|
|
||||||
from .coordinator import PowerviewShadeUpdateCoordinator
|
from .coordinator import PowerviewShadeUpdateCoordinator
|
||||||
from .entity import ShadeEntity
|
from .entity import ShadeEntity
|
||||||
from .model import PowerviewDeviceInfo, PowerviewEntryData
|
from .model import PowerviewConfigEntry, PowerviewDeviceInfo
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
|
||||||
|
|
||||||
|
|
||||||
@dataclass(frozen=True)
|
@dataclass(frozen=True)
|
||||||
|
@ -57,12 +52,12 @@ DROPDOWNS: Final = [
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(
|
async def async_setup_entry(
|
||||||
hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
|
hass: HomeAssistant,
|
||||||
|
entry: PowerviewConfigEntry,
|
||||||
|
async_add_entities: AddEntitiesCallback,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Set up the hunter douglas select entities."""
|
"""Set up the hunter douglas select entities."""
|
||||||
|
pv_entry = entry.runtime_data
|
||||||
pv_entry: PowerviewEntryData = hass.data[DOMAIN][entry.entry_id]
|
|
||||||
|
|
||||||
entities: list[PowerViewSelect] = []
|
entities: list[PowerViewSelect] = []
|
||||||
for shade in pv_entry.shade_data.values():
|
for shade in pv_entry.shade_data.values():
|
||||||
if not shade.has_battery_info():
|
if not shade.has_battery_info():
|
||||||
|
|
|
@ -13,15 +13,13 @@ from homeassistant.components.sensor import (
|
||||||
SensorEntityDescription,
|
SensorEntityDescription,
|
||||||
SensorStateClass,
|
SensorStateClass,
|
||||||
)
|
)
|
||||||
from homeassistant.config_entries import ConfigEntry
|
|
||||||
from homeassistant.const import PERCENTAGE, SIGNAL_STRENGTH_DECIBELS, EntityCategory
|
from homeassistant.const import PERCENTAGE, SIGNAL_STRENGTH_DECIBELS, EntityCategory
|
||||||
from homeassistant.core import HomeAssistant, callback
|
from homeassistant.core import HomeAssistant, callback
|
||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
|
|
||||||
from .const import DOMAIN
|
|
||||||
from .coordinator import PowerviewShadeUpdateCoordinator
|
from .coordinator import PowerviewShadeUpdateCoordinator
|
||||||
from .entity import ShadeEntity
|
from .entity import ShadeEntity
|
||||||
from .model import PowerviewDeviceInfo, PowerviewEntryData
|
from .model import PowerviewConfigEntry, PowerviewDeviceInfo
|
||||||
|
|
||||||
|
|
||||||
@dataclass(frozen=True)
|
@dataclass(frozen=True)
|
||||||
|
@ -79,12 +77,12 @@ SENSORS: Final = [
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(
|
async def async_setup_entry(
|
||||||
hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
|
hass: HomeAssistant,
|
||||||
|
entry: PowerviewConfigEntry,
|
||||||
|
async_add_entities: AddEntitiesCallback,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Set up the hunter douglas sensor entities."""
|
"""Set up the hunter douglas sensor entities."""
|
||||||
|
pv_entry = entry.runtime_data
|
||||||
pv_entry: PowerviewEntryData = hass.data[DOMAIN][entry.entry_id]
|
|
||||||
|
|
||||||
entities: list[PowerViewSensor] = []
|
entities: list[PowerViewSensor] = []
|
||||||
for shade in pv_entry.shade_data.values():
|
for shade in pv_entry.shade_data.values():
|
||||||
room_name = getattr(pv_entry.room_data.get(shade.room_id), ATTR_NAME, "")
|
room_name = getattr(pv_entry.room_data.get(shade.room_id), ATTR_NAME, "")
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from dataclasses import fields
|
from dataclasses import fields
|
||||||
import logging
|
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
from aiopvapi.resources.model import PowerviewData
|
from aiopvapi.resources.model import PowerviewData
|
||||||
|
@ -11,8 +10,6 @@ from aiopvapi.resources.shade import BaseShade, ShadePosition
|
||||||
|
|
||||||
from .util import async_map_data_by_id
|
from .util import async_map_data_by_id
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
|
||||||
|
|
||||||
POSITION_FIELDS = [field for field in fields(ShadePosition) if field.name != "velocity"]
|
POSITION_FIELDS = [field for field in fields(ShadePosition) if field.name != "velocity"]
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue