From 80879cc1def17de84339c963626862ccc52dd60a Mon Sep 17 00:00:00 2001 From: denpamusic Date: Thu, 23 Nov 2023 04:41:47 +0300 Subject: [PATCH] Update PyPlumIO to 0.5.7. - Rename Addressable to AddressableDevice. - Rename REQUEST_DATA_SCHEMA to REQUEST_REGULATOR_DATA_SCHEMA. --- .github/workflows/ci.yml | 2 +- custom_components/plum_ecomax/config_flow.py | 8 ++++---- custom_components/plum_ecomax/connection.py | 14 +++++++------- custom_components/plum_ecomax/manifest.json | 2 +- custom_components/plum_ecomax/select.py | 2 +- tests/test_connection.py | 4 ++-- 6 files changed, 16 insertions(+), 16 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index aead242..3158e4b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,7 +19,7 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - python -m pip install pyplumio==0.5.6 pytest-homeassistant-custom-component psutil-home-assistant fnv-hash-fast aiohttp_cors mypy pylint flake8 flake8-pyproject black + python -m pip install pyplumio==0.5.7 pytest-homeassistant-custom-component psutil-home-assistant fnv-hash-fast aiohttp_cors mypy pylint flake8 flake8-pyproject black - name: Check typing run: | diff --git a/custom_components/plum_ecomax/config_flow.py b/custom_components/plum_ecomax/config_flow.py index f9178bb..ffe1a6f 100644 --- a/custom_components/plum_ecomax/config_flow.py +++ b/custom_components/plum_ecomax/config_flow.py @@ -14,7 +14,7 @@ import homeassistant.helpers.config_validation as cv from pyplumio.connection import Connection from pyplumio.const import ProductType -from pyplumio.devices import Addressable +from pyplumio.devices import AddressableDevice from pyplumio.exceptions import ConnectionFailedError from pyplumio.structures.modules import ConnectedModules from pyplumio.structures.product_info import ProductInfo @@ -92,7 +92,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): def __init__(self) -> None: self.connection: Connection | None = None - self.device: Addressable | None = None + self.device: AddressableDevice | None = None self.device_task: asyncio.Task | None = None self.identify_task: asyncio.Task | None = None self.modules_task: asyncio.Task | None = None @@ -199,7 +199,7 @@ async def async_step_identify(self, user_input=None) -> FlowResult: async def _identify_device() -> None: try: - assert isinstance(self.device, Addressable) + assert isinstance(self.device, AddressableDevice) product: ProductInfo = await self.device.get( ATTR_PRODUCT, timeout=DEFAULT_TIMEOUT ) @@ -245,7 +245,7 @@ async def async_step_discover(self, user_input=None) -> FlowResult: async def _discover_modules() -> None: try: - assert isinstance(self.device, Addressable) + assert isinstance(self.device, AddressableDevice) modules: ConnectedModules = await self.device.get( ATTR_MODULES, timeout=DEFAULT_TIMEOUT ) diff --git a/custom_components/plum_ecomax/connection.py b/custom_components/plum_ecomax/connection.py index 126726a..bcf34bc 100644 --- a/custom_components/plum_ecomax/connection.py +++ b/custom_components/plum_ecomax/connection.py @@ -14,7 +14,7 @@ from homeassistant.helpers.entity import DeviceInfo import pyplumio from pyplumio.const import FrameType, ProductType -from pyplumio.devices import Addressable +from pyplumio.devices import AddressableDevice from .const import ( ATTR_ECOMAX_PARAMETERS, @@ -59,7 +59,7 @@ async def async_get_connection_handler( _LOGGER.debug("Getting connection handler for type: %s...", connection_type) public_ip = await async_get_source_ip(hass, target_ip=IPV4_BROADCAST_ADDR) - ethernet = pyplumio.ethernet_parameters(ip=public_ip) + ethernet = pyplumio.EthernetParameters(ip=public_ip) if connection_type == CONNECTION_TYPE_TCP: return pyplumio.TcpConnection( @@ -75,7 +75,7 @@ async def async_get_connection_handler( ) -async def async_get_sub_devices(device: Addressable) -> list[str]: +async def async_get_sub_devices(device: AddressableDevice) -> list[str]: """Return device subdevices.""" _LOGGER.debug("Checking connected sub-devices...") @@ -113,7 +113,7 @@ class EcomaxConnection: """Represents the ecoMAX connection.""" _connection: pyplumio.Connection - _device: Addressable | None + _device: AddressableDevice | None _hass: HomeAssistant entry: ConfigEntry @@ -136,7 +136,7 @@ def __getattr__(self, name: str): async def async_setup(self) -> None: """Setup connection and add hass stop handler.""" await self.connect() - device: Addressable = await self.get(ECOMAX, timeout=DEFAULT_TIMEOUT) + device: AddressableDevice = await self.get(ECOMAX, timeout=DEFAULT_TIMEOUT) await device.wait_for(ATTR_LOADED, timeout=DEFAULT_TIMEOUT) await device.wait_for(ATTR_SENSORS, timeout=DEFAULT_TIMEOUT) await device.wait_for(ATTR_ECOMAX_PARAMETERS, timeout=DEFAULT_TIMEOUT) @@ -173,7 +173,7 @@ async def async_setup_regdata(self) -> bool: try: return await self.device.request( ATTR_REGDATA, - FrameType.REQUEST_DATA_SCHEMA, + FrameType.REQUEST_REGULATOR_DATA_SCHEMA, retries=5, timeout=DEFAULT_TIMEOUT, ) @@ -205,7 +205,7 @@ def has_mixers(self) -> bool: return ATTR_MIXERS in self.entry.data.get(CONF_SUB_DEVICES, []) @property - def device(self) -> Addressable: + def device(self) -> AddressableDevice: """Return connection state.""" if self._device is None: raise ConfigEntryNotReady("Device not ready") diff --git a/custom_components/plum_ecomax/manifest.json b/custom_components/plum_ecomax/manifest.json index 18ecdec..a6d9796 100644 --- a/custom_components/plum_ecomax/manifest.json +++ b/custom_components/plum_ecomax/manifest.json @@ -16,7 +16,7 @@ "pyplumio" ], "requirements": [ - "pyplumio==0.5.6" + "pyplumio==0.5.7" ], "version": "0.4.1-beta.1" } \ No newline at end of file diff --git a/custom_components/plum_ecomax/select.py b/custom_components/plum_ecomax/select.py index 138426b..ba63395 100644 --- a/custom_components/plum_ecomax/select.py +++ b/custom_components/plum_ecomax/select.py @@ -76,7 +76,7 @@ async def async_update(self, value) -> None: self.async_write_ha_state() -@dataclass(slots=True) +@dataclass(kw_only=True, slots=True) class EcomaxMixerSelectEntityDescription(EcomaxSelectEntityDescription): """Describes mixer select entity.""" diff --git a/tests/test_connection.py b/tests/test_connection.py index 142beaf..6694cf2 100644 --- a/tests/test_connection.py +++ b/tests/test_connection.py @@ -62,7 +62,7 @@ async def test_async_get_connection_handler( async_get_source_ip, ) -> None: """Test helper function to get connection handler.""" - with patch("pyplumio.ethernet_parameters") as mock_ethernet_parameters: + with patch("pyplumio.EthernetParameters") as mock_ethernet_parameters: connection: Connection = await async_get_connection_handler( CONNECTION_TYPE_TCP, hass, tcp_config_data ) @@ -199,7 +199,7 @@ async def test_async_setup_regdata( assert "Timed out while trying to setup regulator data" in caplog.text mock_device.request.assert_any_await( ATTR_REGDATA, - FrameType.REQUEST_DATA_SCHEMA, + FrameType.REQUEST_REGULATOR_DATA_SCHEMA, retries=5, timeout=DEFAULT_TIMEOUT, )