mirror of
https://github.com/home-assistant/core.git
synced 2025-07-17 02:07:09 +00:00
Bump aioshelly to 6.0.0 (#98719)
This commit is contained in:
parent
af689d7c3e
commit
a713d7585f
@ -4,10 +4,10 @@ from __future__ import annotations
|
|||||||
import contextlib
|
import contextlib
|
||||||
from typing import Any, Final
|
from typing import Any, Final
|
||||||
|
|
||||||
from aioshelly.block_device import BlockDevice
|
from aioshelly.block_device import BlockDevice, BlockUpdateType
|
||||||
from aioshelly.common import ConnectionOptions
|
from aioshelly.common import ConnectionOptions
|
||||||
from aioshelly.exceptions import DeviceConnectionError, InvalidAuthError
|
from aioshelly.exceptions import DeviceConnectionError, InvalidAuthError
|
||||||
from aioshelly.rpc_device import RpcDevice, UpdateType
|
from aioshelly.rpc_device import RpcDevice, RpcUpdateType
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
@ -168,7 +168,7 @@ async def _async_setup_block_entry(hass: HomeAssistant, entry: ConfigEntry) -> b
|
|||||||
await hass.config_entries.async_forward_entry_setups(entry, platforms)
|
await hass.config_entries.async_forward_entry_setups(entry, platforms)
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
def _async_device_online(_: Any) -> None:
|
def _async_device_online(_: Any, update_type: BlockUpdateType) -> None:
|
||||||
LOGGER.debug("Device %s is online, resuming setup", entry.title)
|
LOGGER.debug("Device %s is online, resuming setup", entry.title)
|
||||||
shelly_entry_data.device = None
|
shelly_entry_data.device = None
|
||||||
|
|
||||||
@ -253,7 +253,7 @@ async def _async_setup_rpc_entry(hass: HomeAssistant, entry: ConfigEntry) -> boo
|
|||||||
await hass.config_entries.async_forward_entry_setups(entry, platforms)
|
await hass.config_entries.async_forward_entry_setups(entry, platforms)
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
def _async_device_online(_: Any, update_type: UpdateType) -> None:
|
def _async_device_online(_: Any, update_type: RpcUpdateType) -> None:
|
||||||
LOGGER.debug("Device %s is online, resuming setup", entry.title)
|
LOGGER.debug("Device %s is online, resuming setup", entry.title)
|
||||||
shelly_entry_data.device = None
|
shelly_entry_data.device = None
|
||||||
|
|
||||||
|
@ -9,9 +9,9 @@ from typing import Any, Generic, TypeVar, cast
|
|||||||
|
|
||||||
import aioshelly
|
import aioshelly
|
||||||
from aioshelly.ble import async_ensure_ble_enabled, async_stop_scanner
|
from aioshelly.ble import async_ensure_ble_enabled, async_stop_scanner
|
||||||
from aioshelly.block_device import BlockDevice
|
from aioshelly.block_device import BlockDevice, BlockUpdateType
|
||||||
from aioshelly.exceptions import DeviceConnectionError, InvalidAuthError, RpcCallError
|
from aioshelly.exceptions import DeviceConnectionError, InvalidAuthError, RpcCallError
|
||||||
from aioshelly.rpc_device import RpcDevice, UpdateType
|
from aioshelly.rpc_device import RpcDevice, RpcUpdateType
|
||||||
from awesomeversion import AwesomeVersion
|
from awesomeversion import AwesomeVersion
|
||||||
|
|
||||||
from homeassistant.config_entries import ConfigEntry, ConfigEntryState
|
from homeassistant.config_entries import ConfigEntry, ConfigEntryState
|
||||||
@ -295,10 +295,17 @@ class ShellyBlockCoordinator(ShellyCoordinatorBase[BlockDevice]):
|
|||||||
)
|
)
|
||||||
device_update_info(self.hass, self.device, self.entry)
|
device_update_info(self.hass, self.device, self.entry)
|
||||||
|
|
||||||
|
@callback
|
||||||
|
def _async_handle_update(
|
||||||
|
self, device_: BlockDevice, update_type: BlockUpdateType
|
||||||
|
) -> None:
|
||||||
|
"""Handle device update."""
|
||||||
|
self.async_set_updated_data(None)
|
||||||
|
|
||||||
def async_setup(self) -> None:
|
def async_setup(self) -> None:
|
||||||
"""Set up the coordinator."""
|
"""Set up the coordinator."""
|
||||||
super().async_setup()
|
super().async_setup()
|
||||||
self.device.subscribe_updates(self.async_set_updated_data)
|
self.device.subscribe_updates(self._async_handle_update)
|
||||||
|
|
||||||
def shutdown(self) -> None:
|
def shutdown(self) -> None:
|
||||||
"""Shutdown the coordinator."""
|
"""Shutdown the coordinator."""
|
||||||
@ -535,16 +542,18 @@ class ShellyRpcCoordinator(ShellyCoordinatorBase[RpcDevice]):
|
|||||||
)
|
)
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
def _async_handle_update(self, device_: RpcDevice, update_type: UpdateType) -> None:
|
def _async_handle_update(
|
||||||
|
self, device_: RpcDevice, update_type: RpcUpdateType
|
||||||
|
) -> None:
|
||||||
"""Handle device update."""
|
"""Handle device update."""
|
||||||
if update_type is UpdateType.INITIALIZED:
|
if update_type is RpcUpdateType.INITIALIZED:
|
||||||
self.hass.async_create_task(self._async_connected())
|
self.hass.async_create_task(self._async_connected())
|
||||||
self.async_set_updated_data(None)
|
self.async_set_updated_data(None)
|
||||||
elif update_type is UpdateType.DISCONNECTED:
|
elif update_type is RpcUpdateType.DISCONNECTED:
|
||||||
self.hass.async_create_task(self._async_disconnected())
|
self.hass.async_create_task(self._async_disconnected())
|
||||||
elif update_type is UpdateType.STATUS:
|
elif update_type is RpcUpdateType.STATUS:
|
||||||
self.async_set_updated_data(None)
|
self.async_set_updated_data(None)
|
||||||
elif update_type is UpdateType.EVENT and (event := self.device.event):
|
elif update_type is RpcUpdateType.EVENT and (event := self.device.event):
|
||||||
self._async_device_event_handler(event)
|
self._async_device_event_handler(event)
|
||||||
|
|
||||||
def async_setup(self) -> None:
|
def async_setup(self) -> None:
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
"iot_class": "local_push",
|
"iot_class": "local_push",
|
||||||
"loggers": ["aioshelly"],
|
"loggers": ["aioshelly"],
|
||||||
"quality_scale": "platinum",
|
"quality_scale": "platinum",
|
||||||
"requirements": ["aioshelly==5.4.0"],
|
"requirements": ["aioshelly==6.0.0"],
|
||||||
"zeroconf": [
|
"zeroconf": [
|
||||||
{
|
{
|
||||||
"type": "_http._tcp.local.",
|
"type": "_http._tcp.local.",
|
||||||
|
@ -339,7 +339,7 @@ aioruuvigateway==0.1.0
|
|||||||
aiosenz==1.0.0
|
aiosenz==1.0.0
|
||||||
|
|
||||||
# homeassistant.components.shelly
|
# homeassistant.components.shelly
|
||||||
aioshelly==5.4.0
|
aioshelly==6.0.0
|
||||||
|
|
||||||
# homeassistant.components.skybell
|
# homeassistant.components.skybell
|
||||||
aioskybell==22.7.0
|
aioskybell==22.7.0
|
||||||
|
@ -314,7 +314,7 @@ aioruuvigateway==0.1.0
|
|||||||
aiosenz==1.0.0
|
aiosenz==1.0.0
|
||||||
|
|
||||||
# homeassistant.components.shelly
|
# homeassistant.components.shelly
|
||||||
aioshelly==5.4.0
|
aioshelly==6.0.0
|
||||||
|
|
||||||
# homeassistant.components.skybell
|
# homeassistant.components.skybell
|
||||||
aioskybell==22.7.0
|
aioskybell==22.7.0
|
||||||
|
@ -3,8 +3,8 @@ from __future__ import annotations
|
|||||||
|
|
||||||
from unittest.mock import AsyncMock, Mock, PropertyMock, patch
|
from unittest.mock import AsyncMock, Mock, PropertyMock, patch
|
||||||
|
|
||||||
from aioshelly.block_device import BlockDevice
|
from aioshelly.block_device import BlockDevice, BlockUpdateType
|
||||||
from aioshelly.rpc_device import RpcDevice, UpdateType
|
from aioshelly.rpc_device import RpcDevice, RpcUpdateType
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from homeassistant.components.shelly.const import (
|
from homeassistant.components.shelly.const import (
|
||||||
@ -247,7 +247,9 @@ async def mock_block_device():
|
|||||||
with patch("aioshelly.block_device.BlockDevice.create") as block_device_mock:
|
with patch("aioshelly.block_device.BlockDevice.create") as block_device_mock:
|
||||||
|
|
||||||
def update():
|
def update():
|
||||||
block_device_mock.return_value.subscribe_updates.call_args[0][0]({})
|
block_device_mock.return_value.subscribe_updates.call_args[0][0](
|
||||||
|
{}, BlockUpdateType.COAP_PERIODIC
|
||||||
|
)
|
||||||
|
|
||||||
device = Mock(
|
device = Mock(
|
||||||
spec=BlockDevice,
|
spec=BlockDevice,
|
||||||
@ -291,7 +293,7 @@ async def mock_pre_ble_rpc_device():
|
|||||||
|
|
||||||
def update():
|
def update():
|
||||||
rpc_device_mock.return_value.subscribe_updates.call_args[0][0](
|
rpc_device_mock.return_value.subscribe_updates.call_args[0][0](
|
||||||
{}, UpdateType.STATUS
|
{}, RpcUpdateType.STATUS
|
||||||
)
|
)
|
||||||
|
|
||||||
device = _mock_rpc_device("0.11.0")
|
device = _mock_rpc_device("0.11.0")
|
||||||
@ -310,17 +312,17 @@ async def mock_rpc_device():
|
|||||||
|
|
||||||
def update():
|
def update():
|
||||||
rpc_device_mock.return_value.subscribe_updates.call_args[0][0](
|
rpc_device_mock.return_value.subscribe_updates.call_args[0][0](
|
||||||
{}, UpdateType.STATUS
|
{}, RpcUpdateType.STATUS
|
||||||
)
|
)
|
||||||
|
|
||||||
def event():
|
def event():
|
||||||
rpc_device_mock.return_value.subscribe_updates.call_args[0][0](
|
rpc_device_mock.return_value.subscribe_updates.call_args[0][0](
|
||||||
{}, UpdateType.EVENT
|
{}, RpcUpdateType.EVENT
|
||||||
)
|
)
|
||||||
|
|
||||||
def disconnected():
|
def disconnected():
|
||||||
rpc_device_mock.return_value.subscribe_updates.call_args[0][0](
|
rpc_device_mock.return_value.subscribe_updates.call_args[0][0](
|
||||||
{}, UpdateType.DISCONNECTED
|
{}, RpcUpdateType.DISCONNECTED
|
||||||
)
|
)
|
||||||
|
|
||||||
device = _mock_rpc_device("0.12.0")
|
device = _mock_rpc_device("0.12.0")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user