mirror of
https://github.com/home-assistant/core.git
synced 2025-07-15 01:07:10 +00:00
Move vallox base entity to separate module (#126541)
This commit is contained in:
parent
58770e5c79
commit
f5697ad5d2
@ -13,8 +13,6 @@ from homeassistant.config_entries import ConfigEntry
|
|||||||
from homeassistant.const import CONF_HOST, CONF_NAME, Platform
|
from homeassistant.const import CONF_HOST, CONF_NAME, Platform
|
||||||
from homeassistant.core import HomeAssistant, ServiceCall
|
from homeassistant.core import HomeAssistant, ServiceCall
|
||||||
from homeassistant.helpers import config_validation as cv
|
from homeassistant.helpers import config_validation as cv
|
||||||
from homeassistant.helpers.device_registry import DeviceInfo
|
|
||||||
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
|
||||||
|
|
||||||
from .const import (
|
from .const import (
|
||||||
DEFAULT_FAN_SPEED_AWAY,
|
DEFAULT_FAN_SPEED_AWAY,
|
||||||
@ -234,24 +232,3 @@ class ValloxServiceHandler:
|
|||||||
# be observed by all parties involved.
|
# be observed by all parties involved.
|
||||||
if result:
|
if result:
|
||||||
await self._coordinator.async_request_refresh()
|
await self._coordinator.async_request_refresh()
|
||||||
|
|
||||||
|
|
||||||
class ValloxEntity(CoordinatorEntity[ValloxDataUpdateCoordinator]):
|
|
||||||
"""Representation of a Vallox entity."""
|
|
||||||
|
|
||||||
_attr_has_entity_name = True
|
|
||||||
|
|
||||||
def __init__(self, name: str, coordinator: ValloxDataUpdateCoordinator) -> None:
|
|
||||||
"""Initialize a Vallox entity."""
|
|
||||||
super().__init__(coordinator)
|
|
||||||
|
|
||||||
self._device_uuid = self.coordinator.data.uuid
|
|
||||||
assert self.coordinator.config_entry is not None
|
|
||||||
self._attr_device_info = DeviceInfo(
|
|
||||||
identifiers={(DOMAIN, str(self._device_uuid))},
|
|
||||||
manufacturer=DEFAULT_NAME,
|
|
||||||
model=self.coordinator.data.model,
|
|
||||||
name=name,
|
|
||||||
sw_version=self.coordinator.data.sw_version,
|
|
||||||
configuration_url=f"http://{self.coordinator.config_entry.data[CONF_HOST]}",
|
|
||||||
)
|
|
||||||
|
@ -13,9 +13,9 @@ 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 . import ValloxEntity
|
|
||||||
from .const import DOMAIN
|
from .const import DOMAIN
|
||||||
from .coordinator import ValloxDataUpdateCoordinator
|
from .coordinator import ValloxDataUpdateCoordinator
|
||||||
|
from .entity import ValloxEntity
|
||||||
|
|
||||||
|
|
||||||
class ValloxBinarySensorEntity(ValloxEntity, BinarySensorEntity):
|
class ValloxBinarySensorEntity(ValloxEntity, BinarySensorEntity):
|
||||||
|
@ -12,9 +12,9 @@ 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 . import ValloxEntity
|
|
||||||
from .const import DOMAIN
|
from .const import DOMAIN
|
||||||
from .coordinator import ValloxDataUpdateCoordinator
|
from .coordinator import ValloxDataUpdateCoordinator
|
||||||
|
from .entity import ValloxEntity
|
||||||
|
|
||||||
|
|
||||||
class ValloxFilterChangeDateEntity(ValloxEntity, DateEntity):
|
class ValloxFilterChangeDateEntity(ValloxEntity, DateEntity):
|
||||||
|
31
homeassistant/components/vallox/entity.py
Normal file
31
homeassistant/components/vallox/entity.py
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
"""Support for Vallox ventilation units."""
|
||||||
|
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from homeassistant.const import CONF_HOST
|
||||||
|
from homeassistant.helpers.device_registry import DeviceInfo
|
||||||
|
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
||||||
|
|
||||||
|
from .const import DEFAULT_NAME, DOMAIN
|
||||||
|
from .coordinator import ValloxDataUpdateCoordinator
|
||||||
|
|
||||||
|
|
||||||
|
class ValloxEntity(CoordinatorEntity[ValloxDataUpdateCoordinator]):
|
||||||
|
"""Representation of a Vallox entity."""
|
||||||
|
|
||||||
|
_attr_has_entity_name = True
|
||||||
|
|
||||||
|
def __init__(self, name: str, coordinator: ValloxDataUpdateCoordinator) -> None:
|
||||||
|
"""Initialize a Vallox entity."""
|
||||||
|
super().__init__(coordinator)
|
||||||
|
|
||||||
|
self._device_uuid = self.coordinator.data.uuid
|
||||||
|
assert self.coordinator.config_entry is not None
|
||||||
|
self._attr_device_info = DeviceInfo(
|
||||||
|
identifiers={(DOMAIN, str(self._device_uuid))},
|
||||||
|
manufacturer=DEFAULT_NAME,
|
||||||
|
model=self.coordinator.data.model,
|
||||||
|
name=name,
|
||||||
|
sw_version=self.coordinator.data.sw_version,
|
||||||
|
configuration_url=f"http://{self.coordinator.config_entry.data[CONF_HOST]}",
|
||||||
|
)
|
@ -14,7 +14,6 @@ from homeassistant.exceptions import HomeAssistantError
|
|||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
from homeassistant.helpers.typing import StateType
|
from homeassistant.helpers.typing import StateType
|
||||||
|
|
||||||
from . import ValloxEntity
|
|
||||||
from .const import (
|
from .const import (
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
METRIC_KEY_MODE,
|
METRIC_KEY_MODE,
|
||||||
@ -27,6 +26,7 @@ from .const import (
|
|||||||
VALLOX_PROFILE_TO_PRESET_MODE,
|
VALLOX_PROFILE_TO_PRESET_MODE,
|
||||||
)
|
)
|
||||||
from .coordinator import ValloxDataUpdateCoordinator
|
from .coordinator import ValloxDataUpdateCoordinator
|
||||||
|
from .entity import ValloxEntity
|
||||||
|
|
||||||
|
|
||||||
class ExtraStateAttributeDetails(NamedTuple):
|
class ExtraStateAttributeDetails(NamedTuple):
|
||||||
|
@ -16,9 +16,9 @@ from homeassistant.const import EntityCategory, UnitOfTemperature
|
|||||||
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 . import ValloxEntity
|
|
||||||
from .const import DOMAIN
|
from .const import DOMAIN
|
||||||
from .coordinator import ValloxDataUpdateCoordinator
|
from .coordinator import ValloxDataUpdateCoordinator
|
||||||
|
from .entity import ValloxEntity
|
||||||
|
|
||||||
|
|
||||||
class ValloxNumberEntity(ValloxEntity, NumberEntity):
|
class ValloxNumberEntity(ValloxEntity, NumberEntity):
|
||||||
|
@ -25,7 +25,6 @@ from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
|||||||
from homeassistant.helpers.typing import StateType
|
from homeassistant.helpers.typing import StateType
|
||||||
from homeassistant.util import dt as dt_util
|
from homeassistant.util import dt as dt_util
|
||||||
|
|
||||||
from . import ValloxEntity
|
|
||||||
from .const import (
|
from .const import (
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
METRIC_KEY_MODE,
|
METRIC_KEY_MODE,
|
||||||
@ -34,6 +33,7 @@ from .const import (
|
|||||||
VALLOX_PROFILE_TO_PRESET_MODE,
|
VALLOX_PROFILE_TO_PRESET_MODE,
|
||||||
)
|
)
|
||||||
from .coordinator import ValloxDataUpdateCoordinator
|
from .coordinator import ValloxDataUpdateCoordinator
|
||||||
|
from .entity import ValloxEntity
|
||||||
|
|
||||||
|
|
||||||
class ValloxSensorEntity(ValloxEntity, SensorEntity):
|
class ValloxSensorEntity(ValloxEntity, SensorEntity):
|
||||||
|
@ -13,9 +13,9 @@ 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 . import ValloxEntity
|
|
||||||
from .const import DOMAIN
|
from .const import DOMAIN
|
||||||
from .coordinator import ValloxDataUpdateCoordinator
|
from .coordinator import ValloxDataUpdateCoordinator
|
||||||
|
from .entity import ValloxEntity
|
||||||
|
|
||||||
|
|
||||||
class ValloxSwitchEntity(ValloxEntity, SwitchEntity):
|
class ValloxSwitchEntity(ValloxEntity, SwitchEntity):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user