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:
parent
acd88e1c61
commit
dc7231492e
@ -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)
|
||||
|
@ -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]],
|
||||
):
|
||||
|
Loading…
Reference in New Issue
Block a user