Bump screenlogicpy to v0.10.0 (#104866)
parent
6fd96f856d
commit
3b5e498c30
homeassistant/components/screenlogic
|
@ -3,7 +3,7 @@ from dataclasses import dataclass
|
|||
import logging
|
||||
from typing import Any
|
||||
|
||||
from screenlogicpy.const.common import UNIT
|
||||
from screenlogicpy.const.common import UNIT, ScreenLogicCommunicationError
|
||||
from screenlogicpy.const.data import ATTR, DEVICE, VALUE
|
||||
from screenlogicpy.const.msg import CODE
|
||||
from screenlogicpy.device_const.heat import HEAT_MODE
|
||||
|
@ -150,13 +150,16 @@ class ScreenLogicClimate(ScreenLogicPushEntity, ClimateEntity, RestoreEntity):
|
|||
if (temperature := kwargs.get(ATTR_TEMPERATURE)) is None:
|
||||
raise ValueError(f"Expected attribute {ATTR_TEMPERATURE}")
|
||||
|
||||
if not await self.gateway.async_set_heat_temp(
|
||||
int(self._data_key), int(temperature)
|
||||
):
|
||||
try:
|
||||
await self.gateway.async_set_heat_temp(
|
||||
int(self._data_key), int(temperature)
|
||||
)
|
||||
except ScreenLogicCommunicationError as sle:
|
||||
raise HomeAssistantError(
|
||||
f"Failed to set_temperature {temperature} on body"
|
||||
f" {self.entity_data[ATTR.BODY_TYPE][ATTR.VALUE]}"
|
||||
)
|
||||
f" {self.entity_data[ATTR.BODY_TYPE][ATTR.VALUE]}:"
|
||||
f" {sle.msg}"
|
||||
) from sle
|
||||
_LOGGER.debug("Set temperature for body %s to %s", self._data_key, temperature)
|
||||
|
||||
async def async_set_hvac_mode(self, hvac_mode: HVACMode) -> None:
|
||||
|
@ -166,13 +169,14 @@ class ScreenLogicClimate(ScreenLogicPushEntity, ClimateEntity, RestoreEntity):
|
|||
else:
|
||||
mode = HEAT_MODE.parse(self.preset_mode)
|
||||
|
||||
if not await self.gateway.async_set_heat_mode(
|
||||
int(self._data_key), int(mode.value)
|
||||
):
|
||||
try:
|
||||
await self.gateway.async_set_heat_mode(int(self._data_key), int(mode.value))
|
||||
except ScreenLogicCommunicationError as sle:
|
||||
raise HomeAssistantError(
|
||||
f"Failed to set_hvac_mode {mode.name} on body"
|
||||
f" {self.entity_data[ATTR.BODY_TYPE][ATTR.VALUE]}"
|
||||
)
|
||||
f" {self.entity_data[ATTR.BODY_TYPE][ATTR.VALUE]}:"
|
||||
f" {sle.msg}"
|
||||
) from sle
|
||||
_LOGGER.debug("Set hvac_mode on body %s to %s", self._data_key, mode.name)
|
||||
|
||||
async def async_set_preset_mode(self, preset_mode: str) -> None:
|
||||
|
@ -183,13 +187,14 @@ class ScreenLogicClimate(ScreenLogicPushEntity, ClimateEntity, RestoreEntity):
|
|||
if self.hvac_mode == HVACMode.OFF:
|
||||
return
|
||||
|
||||
if not await self.gateway.async_set_heat_mode(
|
||||
int(self._data_key), int(mode.value)
|
||||
):
|
||||
try:
|
||||
await self.gateway.async_set_heat_mode(int(self._data_key), int(mode.value))
|
||||
except ScreenLogicCommunicationError as sle:
|
||||
raise HomeAssistantError(
|
||||
f"Failed to set_preset_mode {mode.name} on body"
|
||||
f" {self.entity_data[ATTR.BODY_TYPE][ATTR.VALUE]}"
|
||||
)
|
||||
f" {self.entity_data[ATTR.BODY_TYPE][ATTR.VALUE]}:"
|
||||
f" {sle.msg}"
|
||||
) from sle
|
||||
_LOGGER.debug("Set preset_mode on body %s to %s", self._data_key, mode.name)
|
||||
|
||||
async def async_added_to_hass(self) -> None:
|
||||
|
|
|
@ -2,8 +2,13 @@
|
|||
from datetime import timedelta
|
||||
import logging
|
||||
|
||||
from screenlogicpy import ScreenLogicError, ScreenLogicGateway
|
||||
from screenlogicpy.const.common import SL_GATEWAY_IP, SL_GATEWAY_NAME, SL_GATEWAY_PORT
|
||||
from screenlogicpy import ScreenLogicGateway
|
||||
from screenlogicpy.const.common import (
|
||||
SL_GATEWAY_IP,
|
||||
SL_GATEWAY_NAME,
|
||||
SL_GATEWAY_PORT,
|
||||
ScreenLogicCommunicationError,
|
||||
)
|
||||
from screenlogicpy.device_const.system import EQUIPMENT_FLAG
|
||||
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
|
@ -91,7 +96,7 @@ class ScreenlogicDataUpdateCoordinator(DataUpdateCoordinator[None]):
|
|||
await self.gateway.async_connect(**connect_info)
|
||||
|
||||
await self._async_update_configured_data()
|
||||
except ScreenLogicError as ex:
|
||||
except ScreenLogicCommunicationError as sle:
|
||||
if self.gateway.is_connected:
|
||||
await self.gateway.async_disconnect()
|
||||
raise UpdateFailed(ex.msg) from ex
|
||||
raise UpdateFailed(sle.msg) from sle
|
||||
|
|
|
@ -8,7 +8,10 @@ ENTITY_MIGRATIONS = {
|
|||
"new_name": "Active Alert",
|
||||
},
|
||||
"chem_calcium_harness": {
|
||||
"new_key": VALUE.CALCIUM_HARNESS,
|
||||
"new_key": VALUE.CALCIUM_HARDNESS,
|
||||
},
|
||||
"calcium_harness": {
|
||||
"new_key": VALUE.CALCIUM_HARDNESS,
|
||||
},
|
||||
"chem_current_orp": {
|
||||
"new_key": VALUE.ORP_NOW,
|
||||
|
|
|
@ -6,7 +6,11 @@ import logging
|
|||
from typing import Any
|
||||
|
||||
from screenlogicpy import ScreenLogicGateway
|
||||
from screenlogicpy.const.common import ON_OFF
|
||||
from screenlogicpy.const.common import (
|
||||
ON_OFF,
|
||||
ScreenLogicCommunicationError,
|
||||
ScreenLogicError,
|
||||
)
|
||||
from screenlogicpy.const.data import ATTR
|
||||
from screenlogicpy.const.msg import CODE
|
||||
|
||||
|
@ -170,8 +174,10 @@ class ScreenLogicCircuitEntity(ScreenLogicPushEntity):
|
|||
await self._async_set_circuit(ON_OFF.OFF)
|
||||
|
||||
async def _async_set_circuit(self, state: ON_OFF) -> None:
|
||||
if not await self.gateway.async_set_circuit(self._data_key, state.value):
|
||||
try:
|
||||
await self.gateway.async_set_circuit(self._data_key, state.value)
|
||||
except (ScreenLogicCommunicationError, ScreenLogicError) as sle:
|
||||
raise HomeAssistantError(
|
||||
f"Failed to set_circuit {self._data_key} {state.value}"
|
||||
)
|
||||
f"Failed to set_circuit {self._data_key} {state.value}: {sle.msg}"
|
||||
) from sle
|
||||
_LOGGER.debug("Set circuit %s %s", self._data_key, state.value)
|
||||
|
|
|
@ -15,5 +15,5 @@
|
|||
"documentation": "https://www.home-assistant.io/integrations/screenlogic",
|
||||
"iot_class": "local_push",
|
||||
"loggers": ["screenlogicpy"],
|
||||
"requirements": ["screenlogicpy==0.9.4"]
|
||||
"requirements": ["screenlogicpy==0.10.0"]
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ from collections.abc import Awaitable, Callable
|
|||
from dataclasses import dataclass
|
||||
import logging
|
||||
|
||||
from screenlogicpy.const.common import ScreenLogicCommunicationError, ScreenLogicError
|
||||
from screenlogicpy.const.data import ATTR, DEVICE, GROUP, VALUE
|
||||
from screenlogicpy.device_const.system import EQUIPMENT_FLAG
|
||||
|
||||
|
@ -15,6 +16,7 @@ from homeassistant.components.number import (
|
|||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import EntityCategory
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.exceptions import HomeAssistantError
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
|
||||
from .const import DOMAIN as SL_DOMAIN
|
||||
|
@ -32,7 +34,6 @@ class ScreenLogicNumberRequiredMixin:
|
|||
"""Describes a required mixin for a ScreenLogic number entity."""
|
||||
|
||||
set_value_name: str
|
||||
set_value_args: tuple[tuple[str | int, ...], ...]
|
||||
|
||||
|
||||
@dataclass
|
||||
|
@ -47,20 +48,12 @@ class ScreenLogicNumberDescription(
|
|||
SUPPORTED_SCG_NUMBERS = [
|
||||
ScreenLogicNumberDescription(
|
||||
set_value_name="async_set_scg_config",
|
||||
set_value_args=(
|
||||
(DEVICE.SCG, GROUP.CONFIGURATION, VALUE.POOL_SETPOINT),
|
||||
(DEVICE.SCG, GROUP.CONFIGURATION, VALUE.SPA_SETPOINT),
|
||||
),
|
||||
data_root=(DEVICE.SCG, GROUP.CONFIGURATION),
|
||||
key=VALUE.POOL_SETPOINT,
|
||||
entity_category=EntityCategory.CONFIG,
|
||||
),
|
||||
ScreenLogicNumberDescription(
|
||||
set_value_name="async_set_scg_config",
|
||||
set_value_args=(
|
||||
(DEVICE.SCG, GROUP.CONFIGURATION, VALUE.POOL_SETPOINT),
|
||||
(DEVICE.SCG, GROUP.CONFIGURATION, VALUE.SPA_SETPOINT),
|
||||
),
|
||||
data_root=(DEVICE.SCG, GROUP.CONFIGURATION),
|
||||
key=VALUE.SPA_SETPOINT,
|
||||
entity_category=EntityCategory.CONFIG,
|
||||
|
@ -113,7 +106,6 @@ class ScreenLogicNumber(ScreenlogicEntity, NumberEntity):
|
|||
f"set_value_name '{entity_description.set_value_name}' is not a coroutine"
|
||||
)
|
||||
self._set_value_func: Callable[..., Awaitable[bool]] = func
|
||||
self._set_value_args = entity_description.set_value_args
|
||||
self._attr_native_unit_of_measurement = get_ha_unit(
|
||||
self.entity_data.get(ATTR.UNIT)
|
||||
)
|
||||
|
@ -138,21 +130,14 @@ class ScreenLogicNumber(ScreenlogicEntity, NumberEntity):
|
|||
async def async_set_native_value(self, value: float) -> None:
|
||||
"""Update the current value."""
|
||||
|
||||
# Current API requires certain values to be set at the same time. This
|
||||
# gathers the existing values and updates the particular value being
|
||||
# set by this entity.
|
||||
args = {}
|
||||
for data_path in self._set_value_args:
|
||||
data_key = data_path[-1]
|
||||
args[data_key] = self.coordinator.gateway.get_value(*data_path, strict=True)
|
||||
|
||||
# Current API requires int values for the currently supported numbers.
|
||||
value = int(value)
|
||||
|
||||
args[self._data_key] = value
|
||||
|
||||
if await self._set_value_func(*args.values()):
|
||||
_LOGGER.debug("Set '%s' to %s", self._data_key, value)
|
||||
await self._async_refresh()
|
||||
else:
|
||||
_LOGGER.debug("Failed to set '%s' to %s", self._data_key, value)
|
||||
try:
|
||||
await self._set_value_func(**{self._data_key: value})
|
||||
except (ScreenLogicCommunicationError, ScreenLogicError) as sle:
|
||||
raise HomeAssistantError(
|
||||
f"Failed to set '{self._data_key}' to {value}: {sle.msg}"
|
||||
) from sle
|
||||
_LOGGER.debug("Set '%s' to %s", self._data_key, value)
|
||||
await self._async_refresh()
|
||||
|
|
|
@ -139,7 +139,7 @@ SUPPORTED_INTELLICHEM_SENSORS = [
|
|||
ScreenLogicPushSensorDescription(
|
||||
subscription_code=CODE.CHEMISTRY_CHANGED,
|
||||
data_root=(DEVICE.INTELLICHEM, GROUP.CONFIGURATION),
|
||||
key=VALUE.CALCIUM_HARNESS,
|
||||
key=VALUE.CALCIUM_HARDNESS,
|
||||
),
|
||||
ScreenLogicPushSensorDescription(
|
||||
subscription_code=CODE.CHEMISTRY_CHANGED,
|
||||
|
|
|
@ -2411,7 +2411,7 @@ satel-integra==0.3.7
|
|||
scapy==2.5.0
|
||||
|
||||
# homeassistant.components.screenlogic
|
||||
screenlogicpy==0.9.4
|
||||
screenlogicpy==0.10.0
|
||||
|
||||
# homeassistant.components.scsgate
|
||||
scsgate==0.1.0
|
||||
|
|
|
@ -1799,7 +1799,7 @@ samsungtvws[async,encrypted]==2.6.0
|
|||
scapy==2.5.0
|
||||
|
||||
# homeassistant.components.screenlogic
|
||||
screenlogicpy==0.9.4
|
||||
screenlogicpy==0.10.0
|
||||
|
||||
# homeassistant.components.backup
|
||||
securetar==2023.3.0
|
||||
|
|
Loading…
Reference in New Issue