mirror of
https://github.com/home-assistant/core.git
synced 2025-07-27 07:07:28 +00:00
Move atag base entity to separate module (#126475)
This commit is contained in:
parent
abceed8112
commit
04e232096f
@ -10,12 +10,7 @@ from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import Platform
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||
from homeassistant.helpers.device_registry import DeviceInfo
|
||||
from homeassistant.helpers.update_coordinator import (
|
||||
CoordinatorEntity,
|
||||
DataUpdateCoordinator,
|
||||
UpdateFailed,
|
||||
)
|
||||
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
@ -64,28 +59,3 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||
if unload_ok:
|
||||
hass.data[DOMAIN].pop(entry.entry_id)
|
||||
return unload_ok
|
||||
|
||||
|
||||
class AtagEntity(CoordinatorEntity[DataUpdateCoordinator[AtagOne]]):
|
||||
"""Defines a base Atag entity."""
|
||||
|
||||
def __init__(
|
||||
self, coordinator: DataUpdateCoordinator[AtagOne], atag_id: str
|
||||
) -> None:
|
||||
"""Initialize the Atag entity."""
|
||||
super().__init__(coordinator)
|
||||
|
||||
self._id = atag_id
|
||||
self._attr_name = DOMAIN.title()
|
||||
self._attr_unique_id = f"{coordinator.data.id}-{atag_id}"
|
||||
|
||||
@property
|
||||
def device_info(self) -> DeviceInfo:
|
||||
"""Return info for device registry."""
|
||||
return DeviceInfo(
|
||||
identifiers={(DOMAIN, self.coordinator.data.id)},
|
||||
manufacturer="Atag",
|
||||
model="Atag One",
|
||||
name="Atag Thermostat",
|
||||
sw_version=self.coordinator.data.apiversion,
|
||||
)
|
||||
|
@ -18,7 +18,8 @@ from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
from homeassistant.util.enum import try_parse_enum
|
||||
|
||||
from . import DOMAIN, AtagEntity
|
||||
from . import DOMAIN
|
||||
from .entity import AtagEntity
|
||||
|
||||
PRESET_MAP = {
|
||||
"Manual": "manual",
|
||||
|
36
homeassistant/components/atag/entity.py
Normal file
36
homeassistant/components/atag/entity.py
Normal file
@ -0,0 +1,36 @@
|
||||
"""The ATAG Integration."""
|
||||
|
||||
from pyatag import AtagOne
|
||||
|
||||
from homeassistant.helpers.device_registry import DeviceInfo
|
||||
from homeassistant.helpers.update_coordinator import (
|
||||
CoordinatorEntity,
|
||||
DataUpdateCoordinator,
|
||||
)
|
||||
|
||||
from . import DOMAIN
|
||||
|
||||
|
||||
class AtagEntity(CoordinatorEntity[DataUpdateCoordinator[AtagOne]]):
|
||||
"""Defines a base Atag entity."""
|
||||
|
||||
def __init__(
|
||||
self, coordinator: DataUpdateCoordinator[AtagOne], atag_id: str
|
||||
) -> None:
|
||||
"""Initialize the Atag entity."""
|
||||
super().__init__(coordinator)
|
||||
|
||||
self._id = atag_id
|
||||
self._attr_name = DOMAIN.title()
|
||||
self._attr_unique_id = f"{coordinator.data.id}-{atag_id}"
|
||||
|
||||
@property
|
||||
def device_info(self) -> DeviceInfo:
|
||||
"""Return info for device registry."""
|
||||
return DeviceInfo(
|
||||
identifiers={(DOMAIN, self.coordinator.data.id)},
|
||||
manufacturer="Atag",
|
||||
model="Atag One",
|
||||
name="Atag Thermostat",
|
||||
sw_version=self.coordinator.data.apiversion,
|
||||
)
|
@ -11,7 +11,8 @@ from homeassistant.const import (
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
|
||||
from . import DOMAIN, AtagEntity
|
||||
from . import DOMAIN
|
||||
from .entity import AtagEntity
|
||||
|
||||
SENSORS = {
|
||||
"Outside Temperature": "outside_temp",
|
||||
|
@ -12,7 +12,8 @@ from homeassistant.const import ATTR_TEMPERATURE, STATE_OFF, Platform, UnitOfTem
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
|
||||
from . import DOMAIN, AtagEntity
|
||||
from . import DOMAIN
|
||||
from .entity import AtagEntity
|
||||
|
||||
OPERATION_LIST = [STATE_OFF, STATE_ECO, STATE_PERFORMANCE]
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user