Add tolo select platform (#60326)

This commit is contained in:
Matthias Lohr 2021-11-25 14:41:57 +01:00 committed by GitHub
parent 9eed18f121
commit 2f0ec0d7e5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 69 additions and 1 deletions

View file

@ -1094,6 +1094,7 @@ omit =
homeassistant/components/tolo/__init__.py
homeassistant/components/tolo/climate.py
homeassistant/components/tolo/light.py
homeassistant/components/tolo/select.py
homeassistant/components/tolo/sensor.py
homeassistant/components/tomato/device_tracker.py
homeassistant/components/toon/__init__.py

View file

@ -22,7 +22,7 @@ from homeassistant.helpers.update_coordinator import (
from .const import DEFAULT_RETRY_COUNT, DEFAULT_RETRY_TIMEOUT, DOMAIN
PLATFORMS = ["climate", "light", "sensor"]
PLATFORMS = ["climate", "light", "select", "sensor"]
_LOGGER = logging.getLogger(__name__)

View file

@ -0,0 +1,51 @@
"""TOLO Sauna Select controls."""
from __future__ import annotations
from tololib.const import LampMode
from homeassistant.components.select import SelectEntity
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import ENTITY_CATEGORY_CONFIG
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 select entities for TOLO Sauna."""
coordinator = hass.data[DOMAIN][entry.entry_id]
async_add_entities([ToloLampModeSelect(coordinator, entry)])
class ToloLampModeSelect(ToloSaunaCoordinatorEntity, SelectEntity):
"""TOLO Sauna lamp mode select."""
_attr_device_class = "tolo__lamp_mode"
_attr_entity_category = ENTITY_CATEGORY_CONFIG
_attr_icon = "mdi:lightbulb-multiple-outline"
_attr_name = "Lamp Mode"
_attr_options = [lamp_mode.name.lower() for lamp_mode in LampMode]
def __init__(
self, coordinator: ToloSaunaUpdateCoordinator, entry: ConfigEntry
) -> None:
"""Initialize lamp mode select entity."""
super().__init__(coordinator, entry)
self._attr_unique_id = f"{entry.entry_id}_lamp_mode"
@property
def current_option(self) -> str:
"""Return current lamp mode."""
return self.coordinator.data.settings.lamp_mode.name.lower()
def select_option(self, option: str) -> None:
"""Select lamp mode."""
self.coordinator.client.set_lamp_mode(LampMode[option.upper()])

View file

@ -0,0 +1,8 @@
{
"state": {
"tolo__lamp_mode": {
"automatic": "automatic",
"manual": "manual"
}
}
}

View file

@ -0,0 +1,8 @@
{
"state": {
"tolo__lamp_mode": {
"automatic": "automatic",
"manual": "manual"
}
}
}