From f4997e46fbb024ba951edcb9a9f82f68cd638b18 Mon Sep 17 00:00:00 2001 From: Marlon Date: Mon, 19 Aug 2024 16:15:27 +0200 Subject: [PATCH] Bump apsystems-ez1 to 2.1.0 (#123225) Library update for apsystems fixing breaking changes --- homeassistant/components/apsystems/binary_sensor.py | 8 ++++---- homeassistant/components/apsystems/manifest.json | 2 +- homeassistant/components/apsystems/switch.py | 7 +++---- requirements_all.txt | 2 +- requirements_test_all.txt | 2 +- tests/components/apsystems/conftest.py | 12 ++++++------ 6 files changed, 16 insertions(+), 17 deletions(-) diff --git a/homeassistant/components/apsystems/binary_sensor.py b/homeassistant/components/apsystems/binary_sensor.py index 528203dc2d96d1..9e361ca883ebcb 100644 --- a/homeassistant/components/apsystems/binary_sensor.py +++ b/homeassistant/components/apsystems/binary_sensor.py @@ -35,28 +35,28 @@ class ApsystemsLocalApiBinarySensorDescription(BinarySensorEntityDescription): translation_key="off_grid_status", device_class=BinarySensorDeviceClass.PROBLEM, entity_category=EntityCategory.DIAGNOSTIC, - is_on=lambda c: bool(c.og), + is_on=lambda c: c.offgrid, ), ApsystemsLocalApiBinarySensorDescription( key="dc_1_short_circuit_error_status", translation_key="dc_1_short_circuit_error_status", device_class=BinarySensorDeviceClass.PROBLEM, entity_category=EntityCategory.DIAGNOSTIC, - is_on=lambda c: bool(c.isce1), + is_on=lambda c: c.shortcircuit_1, ), ApsystemsLocalApiBinarySensorDescription( key="dc_2_short_circuit_error_status", translation_key="dc_2_short_circuit_error_status", device_class=BinarySensorDeviceClass.PROBLEM, entity_category=EntityCategory.DIAGNOSTIC, - is_on=lambda c: bool(c.isce2), + is_on=lambda c: c.shortcircuit_2, ), ApsystemsLocalApiBinarySensorDescription( key="output_fault_status", translation_key="output_fault_status", device_class=BinarySensorDeviceClass.PROBLEM, entity_category=EntityCategory.DIAGNOSTIC, - is_on=lambda c: bool(c.oe), + is_on=lambda c: not c.operating, ), ) diff --git a/homeassistant/components/apsystems/manifest.json b/homeassistant/components/apsystems/manifest.json index cba3e59dba04a6..d312901249ebd8 100644 --- a/homeassistant/components/apsystems/manifest.json +++ b/homeassistant/components/apsystems/manifest.json @@ -6,5 +6,5 @@ "documentation": "https://www.home-assistant.io/integrations/apsystems", "integration_type": "device", "iot_class": "local_polling", - "requirements": ["apsystems-ez1==1.3.3"] + "requirements": ["apsystems-ez1==2.1.0"] } diff --git a/homeassistant/components/apsystems/switch.py b/homeassistant/components/apsystems/switch.py index 405adc94b272d4..93a21ec9f05aab 100644 --- a/homeassistant/components/apsystems/switch.py +++ b/homeassistant/components/apsystems/switch.py @@ -5,7 +5,6 @@ from typing import Any from aiohttp.client_exceptions import ClientConnectionError -from APsystemsEZ1 import Status from homeassistant.components.switch import SwitchDeviceClass, SwitchEntity from homeassistant.core import HomeAssistant @@ -45,12 +44,12 @@ async def async_update(self) -> None: self._attr_available = False else: self._attr_available = True - self._attr_is_on = status == Status.normal + self._attr_is_on = status async def async_turn_on(self, **kwargs: Any) -> None: """Turn the switch on.""" - await self._api.set_device_power_status(0) + await self._api.set_device_power_status(True) async def async_turn_off(self, **kwargs: Any) -> None: """Turn the switch off.""" - await self._api.set_device_power_status(1) + await self._api.set_device_power_status(False) diff --git a/requirements_all.txt b/requirements_all.txt index bc4c0146a38653..e29dbe3a285b4a 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -464,7 +464,7 @@ apprise==1.8.0 aprslib==0.7.2 # homeassistant.components.apsystems -apsystems-ez1==1.3.3 +apsystems-ez1==2.1.0 # homeassistant.components.aqualogic aqualogic==2.6 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index 8f9217e2d73c71..91068c52598d83 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -437,7 +437,7 @@ apprise==1.8.0 aprslib==0.7.2 # homeassistant.components.apsystems -apsystems-ez1==1.3.3 +apsystems-ez1==2.1.0 # homeassistant.components.aranet aranet4==2.3.4 diff --git a/tests/components/apsystems/conftest.py b/tests/components/apsystems/conftest.py index 7e6140e8279eed..0feccf21578925 100644 --- a/tests/components/apsystems/conftest.py +++ b/tests/components/apsystems/conftest.py @@ -3,7 +3,7 @@ from collections.abc import Generator from unittest.mock import AsyncMock, MagicMock, patch -from APsystemsEZ1 import ReturnAlarmInfo, ReturnDeviceInfo, ReturnOutputData, Status +from APsystemsEZ1 import ReturnAlarmInfo, ReturnDeviceInfo, ReturnOutputData import pytest from homeassistant.components.apsystems.const import DOMAIN @@ -53,12 +53,12 @@ def mock_apsystems() -> Generator[MagicMock]: te2=7.0, ) mock_api.get_alarm_info.return_value = ReturnAlarmInfo( - og=Status.normal, - isce1=Status.alarm, - isce2=Status.normal, - oe=Status.alarm, + offgrid=False, + shortcircuit_1=True, + shortcircuit_2=False, + operating=False, ) - mock_api.get_device_power_status.return_value = Status.normal + mock_api.get_device_power_status.return_value = True yield mock_api