mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 19:27:45 +00:00
Add tolo fan platform (#60502)
This commit is contained in:
parent
ec1c52d945
commit
7b81185d2a
@ -1098,6 +1098,7 @@ omit =
|
|||||||
homeassistant/components/tolo/binary_sensor.py
|
homeassistant/components/tolo/binary_sensor.py
|
||||||
homeassistant/components/tolo/button.py
|
homeassistant/components/tolo/button.py
|
||||||
homeassistant/components/tolo/climate.py
|
homeassistant/components/tolo/climate.py
|
||||||
|
homeassistant/components/tolo/fan.py
|
||||||
homeassistant/components/tolo/light.py
|
homeassistant/components/tolo/light.py
|
||||||
homeassistant/components/tolo/select.py
|
homeassistant/components/tolo/select.py
|
||||||
homeassistant/components/tolo/sensor.py
|
homeassistant/components/tolo/sensor.py
|
||||||
|
@ -22,7 +22,15 @@ from homeassistant.helpers.update_coordinator import (
|
|||||||
|
|
||||||
from .const import DEFAULT_RETRY_COUNT, DEFAULT_RETRY_TIMEOUT, DOMAIN
|
from .const import DEFAULT_RETRY_COUNT, DEFAULT_RETRY_TIMEOUT, DOMAIN
|
||||||
|
|
||||||
PLATFORMS = ["binary_sensor", "button", "climate", "light", "select", "sensor"]
|
PLATFORMS = [
|
||||||
|
"binary_sensor",
|
||||||
|
"button",
|
||||||
|
"climate",
|
||||||
|
"fan",
|
||||||
|
"light",
|
||||||
|
"select",
|
||||||
|
"sensor",
|
||||||
|
]
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
56
homeassistant/components/tolo/fan.py
Normal file
56
homeassistant/components/tolo/fan.py
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
"""TOLO Sauna fan controls."""
|
||||||
|
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
|
from homeassistant.components.fan import FanEntity
|
||||||
|
from homeassistant.config_entries import ConfigEntry
|
||||||
|
from homeassistant.core import HomeAssistant
|
||||||
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
|
|
||||||
|
from . import ToloSaunaCoordinatorEntity, ToloSaunaUpdateCoordinator
|
||||||
|
from .const import DOMAIN
|
||||||
|
|
||||||
|
|
||||||
|
async def async_setup_entry(
|
||||||
|
hass: HomeAssistant,
|
||||||
|
entry: ConfigEntry,
|
||||||
|
async_add_entities: AddEntitiesCallback,
|
||||||
|
) -> None:
|
||||||
|
"""Set up fan controls for TOLO Sauna."""
|
||||||
|
coordinator = hass.data[DOMAIN][entry.entry_id]
|
||||||
|
async_add_entities([ToloFan(coordinator, entry)])
|
||||||
|
|
||||||
|
|
||||||
|
class ToloFan(ToloSaunaCoordinatorEntity, FanEntity):
|
||||||
|
"""Sauna fan control."""
|
||||||
|
|
||||||
|
_attr_name = "Fan"
|
||||||
|
|
||||||
|
def __init__(
|
||||||
|
self, coordinator: ToloSaunaUpdateCoordinator, entry: ConfigEntry
|
||||||
|
) -> None:
|
||||||
|
"""Initialize TOLO fan entity."""
|
||||||
|
super().__init__(coordinator, entry)
|
||||||
|
|
||||||
|
self._attr_unique_id = f"{entry.entry_id}_fan"
|
||||||
|
|
||||||
|
@property
|
||||||
|
def is_on(self) -> bool:
|
||||||
|
"""Return if sauna fan is running."""
|
||||||
|
return self.coordinator.data.status.fan_on
|
||||||
|
|
||||||
|
def turn_on(
|
||||||
|
self,
|
||||||
|
speed: str | None = None,
|
||||||
|
percentage: int | None = None,
|
||||||
|
preset_mode: str | None = None,
|
||||||
|
**kwargs: Any,
|
||||||
|
) -> None:
|
||||||
|
"""Turn on sauna fan."""
|
||||||
|
self.coordinator.client.set_fan_on(True)
|
||||||
|
|
||||||
|
def turn_off(self, **kwargs: Any) -> None:
|
||||||
|
"""Turn off sauna fan."""
|
||||||
|
self.coordinator.client.set_fan_on(False)
|
Loading…
x
Reference in New Issue
Block a user