1
mirror of https://github.com/home-assistant/core synced 2024-08-02 23:40:32 +02:00

Address late review in screenlogic (#64529)

Co-authored-by: epenet <epenet@users.noreply.github.com>
This commit is contained in:
epenet 2022-01-20 09:43:23 +01:00 committed by GitHub
parent acd88e1c61
commit dc7231492e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 6 deletions

View File

@ -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)

View File

@ -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]],
):