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