Skip to content

Commit

Permalink
Update PyPlumIO to 0.5.7.
Browse files Browse the repository at this point in the history
- Rename Addressable to AddressableDevice.
- Rename REQUEST_DATA_SCHEMA to REQUEST_REGULATOR_DATA_SCHEMA.
  • Loading branch information
denpamusic committed Nov 23, 2023
1 parent 421c6cd commit 80879cc
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand Down
8 changes: 4 additions & 4 deletions custom_components/plum_ecomax/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
)
Expand Down Expand Up @@ -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
)
Expand Down
14 changes: 7 additions & 7 deletions custom_components/plum_ecomax/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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(
Expand All @@ -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...")

Expand Down Expand Up @@ -113,7 +113,7 @@ class EcomaxConnection:
"""Represents the ecoMAX connection."""

_connection: pyplumio.Connection
_device: Addressable | None
_device: AddressableDevice | None
_hass: HomeAssistant
entry: ConfigEntry

Expand All @@ -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)
Expand Down Expand Up @@ -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,
)
Expand Down Expand Up @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion custom_components/plum_ecomax/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"pyplumio"
],
"requirements": [
"pyplumio==0.5.6"
"pyplumio==0.5.7"
],
"version": "0.4.1-beta.1"
}
2 changes: 1 addition & 1 deletion custom_components/plum_ecomax/select.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""

Expand Down
4 changes: 2 additions & 2 deletions tests/test_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand Down Expand Up @@ -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,
)
Expand Down

0 comments on commit 80879cc

Please sign in to comment.