Skip to content

Commit

Permalink
Move tolo base entity to separate module (home-assistant#126530)
Browse files Browse the repository at this point in the history
  • Loading branch information
epenet authored Sep 23, 2024
1 parent 9fcefca commit df0c806
Show file tree
Hide file tree
Showing 11 changed files with 47 additions and 33 deletions.
25 changes: 1 addition & 24 deletions homeassistant/components/tolo/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,7 @@
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import CONF_HOST, Platform
from homeassistant.core import HomeAssistant
from homeassistant.helpers.device_registry import DeviceInfo
from homeassistant.helpers.update_coordinator import (
CoordinatorEntity,
DataUpdateCoordinator,
UpdateFailed,
)
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed

from .const import DEFAULT_RETRY_COUNT, DEFAULT_RETRY_TIMEOUT, DOMAIN

Expand Down Expand Up @@ -89,21 +84,3 @@ def _get_tolo_sauna_data(self) -> ToloSaunaData:
except TimeoutError as error:
raise UpdateFailed("communication timeout") from error
return ToloSaunaData(status, settings)


class ToloSaunaCoordinatorEntity(CoordinatorEntity[ToloSaunaUpdateCoordinator]):
"""CoordinatorEntity for TOLO Sauna."""

_attr_has_entity_name = True

def __init__(
self, coordinator: ToloSaunaUpdateCoordinator, entry: ConfigEntry
) -> None:
"""Initialize ToloSaunaCoordinatorEntity."""
super().__init__(coordinator)
self._attr_device_info = DeviceInfo(
name="TOLO Sauna",
identifiers={(DOMAIN, entry.entry_id)},
manufacturer="SteamTec",
model=self.coordinator.data.status.model.name.capitalize(),
)
3 changes: 2 additions & 1 deletion homeassistant/components/tolo/binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback

from . import ToloSaunaCoordinatorEntity, ToloSaunaUpdateCoordinator
from . import ToloSaunaUpdateCoordinator
from .const import DOMAIN
from .entity import ToloSaunaCoordinatorEntity


async def async_setup_entry(
Expand Down
3 changes: 2 additions & 1 deletion homeassistant/components/tolo/button.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback

from . import ToloSaunaCoordinatorEntity, ToloSaunaUpdateCoordinator
from . import ToloSaunaUpdateCoordinator
from .const import DOMAIN
from .entity import ToloSaunaCoordinatorEntity


async def async_setup_entry(
Expand Down
3 changes: 2 additions & 1 deletion homeassistant/components/tolo/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback

from . import ToloSaunaCoordinatorEntity, ToloSaunaUpdateCoordinator
from . import ToloSaunaUpdateCoordinator
from .const import DOMAIN
from .entity import ToloSaunaCoordinatorEntity


async def async_setup_entry(
Expand Down
28 changes: 28 additions & 0 deletions homeassistant/components/tolo/entity.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
"""Component to control TOLO Sauna/Steam Bath."""

from __future__ import annotations

from homeassistant.config_entries import ConfigEntry
from homeassistant.helpers.device_registry import DeviceInfo
from homeassistant.helpers.update_coordinator import CoordinatorEntity

from . import ToloSaunaUpdateCoordinator
from .const import DOMAIN


class ToloSaunaCoordinatorEntity(CoordinatorEntity[ToloSaunaUpdateCoordinator]):
"""CoordinatorEntity for TOLO Sauna."""

_attr_has_entity_name = True

def __init__(
self, coordinator: ToloSaunaUpdateCoordinator, entry: ConfigEntry
) -> None:
"""Initialize ToloSaunaCoordinatorEntity."""
super().__init__(coordinator)
self._attr_device_info = DeviceInfo(
name="TOLO Sauna",
identifiers={(DOMAIN, entry.entry_id)},
manufacturer="SteamTec",
model=self.coordinator.data.status.model.name.capitalize(),
)
3 changes: 2 additions & 1 deletion homeassistant/components/tolo/fan.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback

from . import ToloSaunaCoordinatorEntity, ToloSaunaUpdateCoordinator
from . import ToloSaunaUpdateCoordinator
from .const import DOMAIN
from .entity import ToloSaunaCoordinatorEntity


async def async_setup_entry(
Expand Down
3 changes: 2 additions & 1 deletion homeassistant/components/tolo/light.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback

from . import ToloSaunaCoordinatorEntity, ToloSaunaUpdateCoordinator
from . import ToloSaunaUpdateCoordinator
from .const import DOMAIN
from .entity import ToloSaunaCoordinatorEntity


async def async_setup_entry(
Expand Down
3 changes: 2 additions & 1 deletion homeassistant/components/tolo/number.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback

from . import ToloSaunaCoordinatorEntity, ToloSaunaUpdateCoordinator
from . import ToloSaunaUpdateCoordinator
from .const import DOMAIN
from .entity import ToloSaunaCoordinatorEntity


@dataclass(frozen=True, kw_only=True)
Expand Down
3 changes: 2 additions & 1 deletion homeassistant/components/tolo/select.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback

from . import ToloSaunaCoordinatorEntity, ToloSaunaUpdateCoordinator
from . import ToloSaunaUpdateCoordinator
from .const import DOMAIN, AromaTherapySlot, LampMode
from .entity import ToloSaunaCoordinatorEntity


@dataclass(frozen=True, kw_only=True)
Expand Down
3 changes: 2 additions & 1 deletion homeassistant/components/tolo/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback

from . import ToloSaunaCoordinatorEntity, ToloSaunaUpdateCoordinator
from . import ToloSaunaUpdateCoordinator
from .const import DOMAIN
from .entity import ToloSaunaCoordinatorEntity


@dataclass(frozen=True, kw_only=True)
Expand Down
3 changes: 2 additions & 1 deletion homeassistant/components/tolo/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback

from . import ToloSaunaCoordinatorEntity, ToloSaunaUpdateCoordinator
from . import ToloSaunaUpdateCoordinator
from .const import DOMAIN
from .entity import ToloSaunaCoordinatorEntity


@dataclass(frozen=True, kw_only=True)
Expand Down

0 comments on commit df0c806

Please sign in to comment.