diff --git a/custom_components/digitalstrom/switch.py b/custom_components/digitalstrom/switch.py index beecbfc..0349aa5 100644 --- a/custom_components/digitalstrom/switch.py +++ b/custom_components/digitalstrom/switch.py @@ -9,6 +9,7 @@ from homeassistant.helpers.entity import DeviceInfo from homeassistant.helpers.entity_platform import AddEntitiesCallback +from .api.exceptions import ServerError from .const import CONF_DSUID, DOMAIN from .entity import DigitalstromEntity @@ -78,6 +79,7 @@ def __init__(self, channel): self._attr_has_entity_name = False self.entity_id = f"{DOMAIN}.{self.device.dsuid}_{channel.index}" self._attr_name = self.device.name + self.supports_target_value = True @property def is_on(self) -> bool | None: @@ -99,10 +101,15 @@ async def async_turn_off(self, **kwargs: Any) -> None: ) async def async_update(self, **kwargs: Any): - result = await self.client.request( - f"property/getFloating?path=/apartment/zones/zone{self.device.zone_id}/devices/{self.device.dsuid}/status/outputs/powerState/targetValue" - ) - self.last_value = result.get("value", None) + if not self.supports_target_value: + return + try: + result = await self.client.request( + f"property/getFloating?path=/apartment/zones/zone{self.device.zone_id}/devices/{self.device.dsuid}/status/outputs/powerState/targetValue" + ) + self.last_value = result.get("value", None) + except ServerError: + self.supports_target_value = False class DigitalstromApartmentScene(SwitchEntity):