mirror of
https://github.com/home-assistant/core.git
synced 2025-07-24 05:37:44 +00:00
Move openuv base entity to separate module (#126506)
This commit is contained in:
parent
d67a1993d0
commit
61de70c1df
@ -19,9 +19,6 @@ from homeassistant.const import (
|
||||
)
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers import aiohttp_client
|
||||
from homeassistant.helpers.device_registry import DeviceEntryType, DeviceInfo
|
||||
from homeassistant.helpers.entity import EntityDescription
|
||||
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
||||
|
||||
from .const import (
|
||||
CONF_FROM_WINDOW,
|
||||
@ -110,26 +107,3 @@ async def async_migrate_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||
LOGGER.debug("Migration to version %s successful", version)
|
||||
|
||||
return True
|
||||
|
||||
|
||||
class OpenUvEntity(CoordinatorEntity):
|
||||
"""Define a generic OpenUV entity."""
|
||||
|
||||
_attr_has_entity_name = True
|
||||
|
||||
def __init__(
|
||||
self, coordinator: OpenUvCoordinator, description: EntityDescription
|
||||
) -> None:
|
||||
"""Initialize."""
|
||||
super().__init__(coordinator)
|
||||
|
||||
self._attr_extra_state_attributes = {}
|
||||
self._attr_unique_id = (
|
||||
f"{coordinator.latitude}_{coordinator.longitude}_{description.key}"
|
||||
)
|
||||
self.entity_description = description
|
||||
self._attr_device_info = DeviceInfo(
|
||||
identifiers={(DOMAIN, f"{coordinator.latitude}_{coordinator.longitude}")},
|
||||
name="OpenUV",
|
||||
entry_type=DeviceEntryType.SERVICE,
|
||||
)
|
||||
|
@ -9,9 +9,9 @@ from homeassistant.core import HomeAssistant, callback
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
from homeassistant.util.dt import as_local, parse_datetime, utcnow
|
||||
|
||||
from . import OpenUvEntity
|
||||
from .const import DATA_PROTECTION_WINDOW, DOMAIN, LOGGER, TYPE_PROTECTION_WINDOW
|
||||
from .coordinator import OpenUvCoordinator
|
||||
from .entity import OpenUvEntity
|
||||
|
||||
ATTR_PROTECTION_WINDOW_ENDING_TIME = "end_time"
|
||||
ATTR_PROTECTION_WINDOW_ENDING_UV = "end_uv"
|
||||
|
33
homeassistant/components/openuv/entity.py
Normal file
33
homeassistant/components/openuv/entity.py
Normal file
@ -0,0 +1,33 @@
|
||||
"""Support for UV data from openuv.io."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from homeassistant.helpers.device_registry import DeviceEntryType, DeviceInfo
|
||||
from homeassistant.helpers.entity import EntityDescription
|
||||
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
||||
|
||||
from .const import DOMAIN
|
||||
from .coordinator import OpenUvCoordinator
|
||||
|
||||
|
||||
class OpenUvEntity(CoordinatorEntity):
|
||||
"""Define a generic OpenUV entity."""
|
||||
|
||||
_attr_has_entity_name = True
|
||||
|
||||
def __init__(
|
||||
self, coordinator: OpenUvCoordinator, description: EntityDescription
|
||||
) -> None:
|
||||
"""Initialize."""
|
||||
super().__init__(coordinator)
|
||||
|
||||
self._attr_extra_state_attributes = {}
|
||||
self._attr_unique_id = (
|
||||
f"{coordinator.latitude}_{coordinator.longitude}_{description.key}"
|
||||
)
|
||||
self.entity_description = description
|
||||
self._attr_device_info = DeviceInfo(
|
||||
identifiers={(DOMAIN, f"{coordinator.latitude}_{coordinator.longitude}")},
|
||||
name="OpenUV",
|
||||
entry_type=DeviceEntryType.SERVICE,
|
||||
)
|
@ -18,7 +18,6 @@ from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
from homeassistant.util.dt import as_local, parse_datetime
|
||||
|
||||
from . import OpenUvEntity
|
||||
from .const import (
|
||||
DATA_UV,
|
||||
DOMAIN,
|
||||
@ -34,6 +33,7 @@ from .const import (
|
||||
TYPE_SAFE_EXPOSURE_TIME_6,
|
||||
)
|
||||
from .coordinator import OpenUvCoordinator
|
||||
from .entity import OpenUvEntity
|
||||
|
||||
ATTR_MAX_UV_TIME = "time"
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user