From 0d2ec6cd5c6460a980dc962b69e670bc8bdaac27 Mon Sep 17 00:00:00 2001 From: Marc Mueller <30130371+cdce8p@users.noreply.github.com> Date: Tue, 26 Dec 2023 13:11:05 +0100 Subject: [PATCH] Improve drop_connect typing (#106404) --- homeassistant/components/drop_connect/binary_sensor.py | 2 +- homeassistant/components/drop_connect/coordinator.py | 2 +- homeassistant/components/drop_connect/select.py | 5 +++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/homeassistant/components/drop_connect/binary_sensor.py b/homeassistant/components/drop_connect/binary_sensor.py index 4c392eb8ce1..1bce60f87b3 100644 --- a/homeassistant/components/drop_connect/binary_sensor.py +++ b/homeassistant/components/drop_connect/binary_sensor.py @@ -49,7 +49,7 @@ SALT_LOW = "salt" class DROPBinarySensorEntityDescription(BinarySensorEntityDescription): """Describes DROP binary sensor entity.""" - value_fn: Callable[[DROPDeviceDataUpdateCoordinator], bool | None] + value_fn: Callable[[DROPDeviceDataUpdateCoordinator], int | None] BINARY_SENSORS: list[DROPBinarySensorEntityDescription] = [ diff --git a/homeassistant/components/drop_connect/coordinator.py b/homeassistant/components/drop_connect/coordinator.py index 67409528402..e4937ed5f65 100644 --- a/homeassistant/components/drop_connect/coordinator.py +++ b/homeassistant/components/drop_connect/coordinator.py @@ -15,7 +15,7 @@ from .const import CONF_COMMAND_TOPIC, DOMAIN _LOGGER = logging.getLogger(__name__) -class DROPDeviceDataUpdateCoordinator(DataUpdateCoordinator): +class DROPDeviceDataUpdateCoordinator(DataUpdateCoordinator[None]): """DROP device object.""" config_entry: ConfigEntry diff --git a/homeassistant/components/drop_connect/select.py b/homeassistant/components/drop_connect/select.py index 365345e147d..e026cfcd59e 100644 --- a/homeassistant/components/drop_connect/select.py +++ b/homeassistant/components/drop_connect/select.py @@ -30,7 +30,7 @@ FLOOD_ICON = "mdi:home-flood" class DROPSelectEntityDescription(SelectEntityDescription): """Describes DROP select entity.""" - value_fn: Callable[[DROPDeviceDataUpdateCoordinator], str | None] + value_fn: Callable[[DROPDeviceDataUpdateCoordinator], int | None] set_fn: Callable[[DROPDeviceDataUpdateCoordinator, str], Awaitable[Any]] @@ -88,7 +88,8 @@ class DROPSelect(DROPEntity, SelectEntity): @property def current_option(self) -> str | None: """Return the current selected option.""" - return self.entity_description.value_fn(self.coordinator) + val = self.entity_description.value_fn(self.coordinator) + return str(val) if val else None async def async_select_option(self, option: str) -> None: """Update the current selected option."""