From dc7231492ead14402922dd61b1dc8f67647135b1 Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Thu, 20 Jan 2022 09:43:23 +0100 Subject: [PATCH] Address late review in screenlogic (#64529) Co-authored-by: epenet --- homeassistant/components/screenlogic/__init__.py | 2 ++ homeassistant/components/screenlogic/number.py | 9 +++------ 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/homeassistant/components/screenlogic/__init__.py b/homeassistant/components/screenlogic/__init__.py index eac3148ec3a..b5f16574f1a 100644 --- a/homeassistant/components/screenlogic/__init__.py +++ b/homeassistant/components/screenlogic/__init__.py @@ -170,6 +170,8 @@ class ScreenlogicDataUpdateCoordinator(DataUpdateCoordinator): class ScreenlogicEntity(CoordinatorEntity): """Base class for all ScreenLogic entities.""" + coordinator: ScreenlogicDataUpdateCoordinator + def __init__(self, coordinator, data_key, enabled=True): """Initialize of the entity.""" super().__init__(coordinator) diff --git a/homeassistant/components/screenlogic/number.py b/homeassistant/components/screenlogic/number.py index de634feaef9..253b5c9641e 100644 --- a/homeassistant/components/screenlogic/number.py +++ b/homeassistant/components/screenlogic/number.py @@ -1,6 +1,5 @@ """Support for a ScreenLogic number entity.""" import logging -from typing import cast from screenlogicpy.const import BODY_TYPE, DATA as SL_DATA, EQUIPMENT, SCG @@ -9,7 +8,7 @@ from homeassistant.config_entries import ConfigEntry from homeassistant.core import HomeAssistant from homeassistant.helpers.entity_platform import AddEntitiesCallback -from . import ScreenlogicDataUpdateCoordinator, ScreenlogicEntity +from . import ScreenlogicEntity from .const import DOMAIN _LOGGER = logging.getLogger(__name__) @@ -58,16 +57,14 @@ class ScreenLogicNumber(ScreenlogicEntity, NumberEntity): async def async_set_value(self, value: float) -> None: """Update the current value.""" - coordinator = cast(ScreenlogicDataUpdateCoordinator, self.coordinator) - # Need to set both levels at the same time, so we gather # both existing level values and override the one that changed. levels = {} for level in SUPPORTED_SCG_NUMBERS: - levels[level] = coordinator.data[SL_DATA.KEY_SCG][level]["value"] + levels[level] = self.coordinator.data[SL_DATA.KEY_SCG][level]["value"] levels[self._data_key] = int(value) - if await coordinator.gateway.async_set_scg_config( + if await self.coordinator.gateway.async_set_scg_config( levels[SUPPORTED_SCG_NUMBERS[BODY_TYPE.POOL]], levels[SUPPORTED_SCG_NUMBERS[BODY_TYPE.SPA]], ):