Bump aioshelly to 10.0.0 (#117728)

This commit is contained in:
Shay Levy 2024-05-19 20:25:12 +03:00 committed by GitHub
parent 38f0c47942
commit d84890bc59
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 21 additions and 38 deletions

View file

@ -328,6 +328,6 @@ async def async_unload_entry(hass: HomeAssistant, entry: ShellyConfigEntry) -> b
if unload_ok := await hass.config_entries.async_unload_platforms(entry, platforms): if unload_ok := await hass.config_entries.async_unload_platforms(entry, platforms):
if shelly_entry_data.block: if shelly_entry_data.block:
shelly_entry_data.block.shutdown() await shelly_entry_data.block.shutdown()
return unload_ok return unload_ok

View file

@ -122,7 +122,7 @@ async def validate_input(
options, options,
) )
await block_device.initialize() await block_device.initialize()
block_device.shutdown() await block_device.shutdown()
return { return {
"title": block_device.name, "title": block_device.name,
CONF_SLEEP_PERIOD: get_block_device_sleep_period(block_device.settings), CONF_SLEEP_PERIOD: get_block_device_sleep_period(block_device.settings),

View file

@ -63,7 +63,6 @@ from .const import (
) )
from .utils import ( from .utils import (
async_create_issue_unsupported_firmware, async_create_issue_unsupported_firmware,
async_shutdown_device,
get_block_device_sleep_period, get_block_device_sleep_period,
get_device_entry_gen, get_device_entry_gen,
get_http_port, get_http_port,
@ -115,6 +114,10 @@ class ShellyCoordinatorBase(DataUpdateCoordinator[None], Generic[_DeviceT]):
) )
entry.async_on_unload(self._debounced_reload.async_shutdown) entry.async_on_unload(self._debounced_reload.async_shutdown)
entry.async_on_unload(
hass.bus.async_listen_once(EVENT_HOMEASSISTANT_STOP, self._handle_ha_stop)
)
@property @property
def model(self) -> str: def model(self) -> str:
"""Model of the device.""" """Model of the device."""
@ -151,6 +154,15 @@ class ShellyCoordinatorBase(DataUpdateCoordinator[None], Generic[_DeviceT]):
) )
self.device_id = device_entry.id self.device_id = device_entry.id
async def shutdown(self) -> None:
"""Shutdown the coordinator."""
await self.device.shutdown()
async def _handle_ha_stop(self, _event: Event) -> None:
"""Handle Home Assistant stopping."""
LOGGER.debug("Stopping RPC device coordinator for %s", self.name)
await self.shutdown()
async def _async_device_connect_task(self) -> bool: async def _async_device_connect_task(self) -> bool:
"""Connect to a Shelly device task.""" """Connect to a Shelly device task."""
LOGGER.debug("Connecting to Shelly Device - %s", self.name) LOGGER.debug("Connecting to Shelly Device - %s", self.name)
@ -206,7 +218,7 @@ class ShellyCoordinatorBase(DataUpdateCoordinator[None], Generic[_DeviceT]):
# not running disconnect events since we have auth error # not running disconnect events since we have auth error
# and won't be able to send commands to the device # and won't be able to send commands to the device
self.last_update_success = False self.last_update_success = False
await async_shutdown_device(self.device) await self.shutdown()
self.entry.async_start_reauth(self.hass) self.entry.async_start_reauth(self.hass)
@ -237,9 +249,6 @@ class ShellyBlockCoordinator(ShellyCoordinatorBase[BlockDevice]):
entry.async_on_unload( entry.async_on_unload(
self.async_add_listener(self._async_device_updates_handler) self.async_add_listener(self._async_device_updates_handler)
) )
entry.async_on_unload(
hass.bus.async_listen_once(EVENT_HOMEASSISTANT_STOP, self._handle_ha_stop)
)
@callback @callback
def async_subscribe_input_events( def async_subscribe_input_events(
@ -407,16 +416,6 @@ class ShellyBlockCoordinator(ShellyCoordinatorBase[BlockDevice]):
super().async_setup(pending_platforms) super().async_setup(pending_platforms)
self.device.subscribe_updates(self._async_handle_update) self.device.subscribe_updates(self._async_handle_update)
def shutdown(self) -> None:
"""Shutdown the coordinator."""
self.device.shutdown()
@callback
def _handle_ha_stop(self, _event: Event) -> None:
"""Handle Home Assistant stopping."""
LOGGER.debug("Stopping block device coordinator for %s", self.name)
self.shutdown()
class ShellyRestCoordinator(ShellyCoordinatorBase[BlockDevice]): class ShellyRestCoordinator(ShellyCoordinatorBase[BlockDevice]):
"""Coordinator for a Shelly REST device.""" """Coordinator for a Shelly REST device."""
@ -473,9 +472,6 @@ class ShellyRpcCoordinator(ShellyCoordinatorBase[RpcDevice]):
self._ota_event_listeners: list[Callable[[dict[str, Any]], None]] = [] self._ota_event_listeners: list[Callable[[dict[str, Any]], None]] = []
self._input_event_listeners: list[Callable[[dict[str, Any]], None]] = [] self._input_event_listeners: list[Callable[[dict[str, Any]], None]] = []
entry.async_on_unload(
hass.bus.async_listen_once(EVENT_HOMEASSISTANT_STOP, self._handle_ha_stop)
)
entry.async_on_unload(entry.add_update_listener(self._async_update_listener)) entry.async_on_unload(entry.add_update_listener(self._async_update_listener))
def update_sleep_period(self) -> bool: def update_sleep_period(self) -> bool:
@ -705,16 +701,11 @@ class ShellyRpcCoordinator(ShellyCoordinatorBase[RpcDevice]):
try: try:
await async_stop_scanner(self.device) await async_stop_scanner(self.device)
except InvalidAuthError: except InvalidAuthError:
await self.async_shutdown_device_and_start_reauth() self.entry.async_start_reauth(self.hass)
return return
await self.device.shutdown() await super().shutdown()
await self._async_disconnected(False) await self._async_disconnected(False)
async def _handle_ha_stop(self, _event: Event) -> None:
"""Handle Home Assistant stopping."""
LOGGER.debug("Stopping RPC device coordinator for %s", self.name)
await self.shutdown()
class ShellyRpcPollingCoordinator(ShellyCoordinatorBase[RpcDevice]): class ShellyRpcPollingCoordinator(ShellyCoordinatorBase[RpcDevice]):
"""Polling coordinator for a Shelly RPC based device.""" """Polling coordinator for a Shelly RPC based device."""

View file

@ -9,7 +9,7 @@
"iot_class": "local_push", "iot_class": "local_push",
"loggers": ["aioshelly"], "loggers": ["aioshelly"],
"quality_scale": "platinum", "quality_scale": "platinum",
"requirements": ["aioshelly==9.0.0"], "requirements": ["aioshelly==10.0.0"],
"zeroconf": [ "zeroconf": [
{ {
"type": "_http._tcp.local.", "type": "_http._tcp.local.",

View file

@ -482,14 +482,6 @@ def get_http_port(data: MappingProxyType[str, Any]) -> int:
return cast(int, data.get(CONF_PORT, DEFAULT_HTTP_PORT)) return cast(int, data.get(CONF_PORT, DEFAULT_HTTP_PORT))
async def async_shutdown_device(device: BlockDevice | RpcDevice) -> None:
"""Shutdown a Shelly device."""
if isinstance(device, RpcDevice):
await device.shutdown()
if isinstance(device, BlockDevice):
device.shutdown()
@callback @callback
def async_remove_shelly_rpc_entities( def async_remove_shelly_rpc_entities(
hass: HomeAssistant, domain: str, mac: str, keys: list[str] hass: HomeAssistant, domain: str, mac: str, keys: list[str]

View file

@ -356,7 +356,7 @@ aioruuvigateway==0.1.0
aiosenz==1.0.0 aiosenz==1.0.0
# homeassistant.components.shelly # homeassistant.components.shelly
aioshelly==9.0.0 aioshelly==10.0.0
# homeassistant.components.skybell # homeassistant.components.skybell
aioskybell==22.7.0 aioskybell==22.7.0

View file

@ -329,7 +329,7 @@ aioruuvigateway==0.1.0
aiosenz==1.0.0 aiosenz==1.0.0
# homeassistant.components.shelly # homeassistant.components.shelly
aioshelly==9.0.0 aioshelly==10.0.0
# homeassistant.components.skybell # homeassistant.components.skybell
aioskybell==22.7.0 aioskybell==22.7.0