mirror of
https://github.com/home-assistant/core.git
synced 2025-07-24 21:57:51 +00: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):
|
class ScreenlogicEntity(CoordinatorEntity):
|
||||||
"""Base class for all ScreenLogic entities."""
|
"""Base class for all ScreenLogic entities."""
|
||||||
|
|
||||||
|
coordinator: ScreenlogicDataUpdateCoordinator
|
||||||
|
|
||||||
def __init__(self, coordinator, data_key, enabled=True):
|
def __init__(self, coordinator, data_key, enabled=True):
|
||||||
"""Initialize of the entity."""
|
"""Initialize of the entity."""
|
||||||
super().__init__(coordinator)
|
super().__init__(coordinator)
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
"""Support for a ScreenLogic number entity."""
|
"""Support for a ScreenLogic number entity."""
|
||||||
import logging
|
import logging
|
||||||
from typing import cast
|
|
||||||
|
|
||||||
from screenlogicpy.const import BODY_TYPE, DATA as SL_DATA, EQUIPMENT, SCG
|
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.core import HomeAssistant
|
||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
|
|
||||||
from . import ScreenlogicDataUpdateCoordinator, ScreenlogicEntity
|
from . import ScreenlogicEntity
|
||||||
from .const import DOMAIN
|
from .const import DOMAIN
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
@ -58,16 +57,14 @@ class ScreenLogicNumber(ScreenlogicEntity, NumberEntity):
|
|||||||
|
|
||||||
async def async_set_value(self, value: float) -> None:
|
async def async_set_value(self, value: float) -> None:
|
||||||
"""Update the current value."""
|
"""Update the current value."""
|
||||||
coordinator = cast(ScreenlogicDataUpdateCoordinator, self.coordinator)
|
|
||||||
|
|
||||||
# Need to set both levels at the same time, so we gather
|
# Need to set both levels at the same time, so we gather
|
||||||
# both existing level values and override the one that changed.
|
# both existing level values and override the one that changed.
|
||||||
levels = {}
|
levels = {}
|
||||||
for level in SUPPORTED_SCG_NUMBERS:
|
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)
|
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.POOL]],
|
||||||
levels[SUPPORTED_SCG_NUMBERS[BODY_TYPE.SPA]],
|
levels[SUPPORTED_SCG_NUMBERS[BODY_TYPE.SPA]],
|
||||||
):
|
):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user