Bump screenlogicpy to v0.8.2 (#89832)
parent
95515fbe78
commit
b403a96ea0
|
@ -10,7 +10,6 @@ from screenlogicpy.const import (
|
|||
SL_GATEWAY_IP,
|
||||
SL_GATEWAY_NAME,
|
||||
SL_GATEWAY_PORT,
|
||||
ScreenLogicWarning,
|
||||
)
|
||||
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
|
@ -52,8 +51,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||
try:
|
||||
await gateway.async_connect(**connect_info)
|
||||
except ScreenLogicError as ex:
|
||||
_LOGGER.error("Error while connecting to the gateway %s: %s", connect_info, ex)
|
||||
raise ConfigEntryNotReady from ex
|
||||
raise ConfigEntryNotReady(ex.msg) from ex
|
||||
|
||||
coordinator = ScreenlogicDataUpdateCoordinator(
|
||||
hass, config_entry=entry, gateway=gateway
|
||||
|
@ -157,25 +155,17 @@ class ScreenlogicDataUpdateCoordinator(DataUpdateCoordinator[None]):
|
|||
|
||||
async def _async_update_data(self) -> None:
|
||||
"""Fetch data from the Screenlogic gateway."""
|
||||
try:
|
||||
await self._async_update_configured_data()
|
||||
except (ScreenLogicError, ScreenLogicWarning) as ex:
|
||||
_LOGGER.warning("Update error - attempting reconnect: %s", ex)
|
||||
await self._async_reconnect_update_data()
|
||||
|
||||
return None
|
||||
|
||||
async def _async_reconnect_update_data(self) -> None:
|
||||
"""Attempt to reconnect to the gateway and fetch data."""
|
||||
assert self.config_entry is not None
|
||||
try:
|
||||
# Clean up the previous connection as we're about to create a new one
|
||||
await self.gateway.async_disconnect()
|
||||
|
||||
connect_info = await async_get_connect_info(self.hass, self.config_entry)
|
||||
await self.gateway.async_connect(**connect_info)
|
||||
if not self.gateway.is_connected:
|
||||
connect_info = await async_get_connect_info(
|
||||
self.hass, self.config_entry
|
||||
)
|
||||
await self.gateway.async_connect(**connect_info)
|
||||
|
||||
await self._async_update_configured_data()
|
||||
|
||||
except (ScreenLogicError, ScreenLogicWarning) as ex:
|
||||
raise UpdateFailed(ex) from ex
|
||||
except ScreenLogicError as ex:
|
||||
if self.gateway.is_connected:
|
||||
await self.gateway.async_disconnect()
|
||||
raise UpdateFailed(ex.msg) from ex
|
||||
return None
|
||||
|
|
|
@ -101,21 +101,30 @@ class ScreenLogicPushEntity(ScreenlogicEntity):
|
|||
"""Initialize the entity."""
|
||||
super().__init__(coordinator, data_key, enabled)
|
||||
self._update_message_code = message_code
|
||||
self._last_update_success = True
|
||||
|
||||
@callback
|
||||
def _async_data_updated(self) -> None:
|
||||
"""Handle data updates."""
|
||||
self._last_update_success = self.coordinator.last_update_success
|
||||
self.async_write_ha_state()
|
||||
|
||||
async def async_added_to_hass(self) -> None:
|
||||
"""When entity is added to hass."""
|
||||
|
||||
await super().async_added_to_hass()
|
||||
self.async_on_remove(
|
||||
await self.gateway.async_subscribe_client(
|
||||
self._async_data_updated, self._update_message_code
|
||||
)
|
||||
)
|
||||
|
||||
@callback
|
||||
def _handle_coordinator_update(self) -> None:
|
||||
"""Handle updated data from the coordinator."""
|
||||
# For push entities, only take updates from the coordinator if availability changes.
|
||||
if self.coordinator.last_update_success != self._last_update_success:
|
||||
self._async_data_updated()
|
||||
|
||||
|
||||
class ScreenLogicCircuitEntity(ScreenLogicPushEntity):
|
||||
"""Base class for all ScreenLogic switch and light entities."""
|
||||
|
|
|
@ -15,5 +15,5 @@
|
|||
"documentation": "https://www.home-assistant.io/integrations/screenlogic",
|
||||
"iot_class": "local_push",
|
||||
"loggers": ["screenlogicpy"],
|
||||
"requirements": ["screenlogicpy==0.7.2"]
|
||||
"requirements": ["screenlogicpy==0.8.2"]
|
||||
}
|
||||
|
|
|
@ -2303,7 +2303,7 @@ satel_integra==0.3.7
|
|||
scapy==2.5.0
|
||||
|
||||
# homeassistant.components.screenlogic
|
||||
screenlogicpy==0.7.2
|
||||
screenlogicpy==0.8.2
|
||||
|
||||
# homeassistant.components.scsgate
|
||||
scsgate==0.1.0
|
||||
|
|
|
@ -1636,7 +1636,7 @@ samsungtvws[async,encrypted]==2.5.0
|
|||
scapy==2.5.0
|
||||
|
||||
# homeassistant.components.screenlogic
|
||||
screenlogicpy==0.7.2
|
||||
screenlogicpy==0.8.2
|
||||
|
||||
# homeassistant.components.backup
|
||||
securetar==2022.2.0
|
||||
|
|
Loading…
Reference in New Issue