From 91ca4e2f9536de87dabe36e321b640c6e3d67deb Mon Sep 17 00:00:00 2001 From: Paul Frank Date: Fri, 20 Dec 2024 12:18:20 +0000 Subject: [PATCH] fixes --- custom_components/stiebel_eltron_isg/config_flow.py | 8 +++++--- custom_components/stiebel_eltron_isg/coordinator.py | 2 +- custom_components/stiebel_eltron_isg/diagnostics.py | 4 ++-- custom_components/stiebel_eltron_isg/lwz_coordinator.py | 4 ++-- custom_components/stiebel_eltron_isg/switch.py | 2 +- custom_components/stiebel_eltron_isg/wpm_coordinator.py | 6 +++--- pyproject.toml | 3 +++ uv.lock | 2 +- 8 files changed, 18 insertions(+), 13 deletions(-) diff --git a/custom_components/stiebel_eltron_isg/config_flow.py b/custom_components/stiebel_eltron_isg/config_flow.py index f936128..224636b 100644 --- a/custom_components/stiebel_eltron_isg/config_flow.py +++ b/custom_components/stiebel_eltron_isg/config_flow.py @@ -1,10 +1,12 @@ """Adds config flow for Stiebel Eltron ISG.""" +from __future__ import annotations + import ipaddress import re import voluptuous as vol -from homeassistant import config_entries +from homeassistant.config_entries import ConfigFlow, CONN_CLASS_LOCAL_POLL from homeassistant.const import CONF_HOST, CONF_NAME, CONF_PORT, CONF_SCAN_INTERVAL from homeassistant.core import HomeAssistant, callback @@ -52,11 +54,11 @@ def stiebeleltron_entries(hass: HomeAssistant): } -class StiebelEltronISGFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): +class StiebelEltronISGFlowHandler(ConfigFlow, domain=DOMAIN): """Config flow for Stiebel Eltron ISG.""" VERSION = 1 - CONNECTION_CLASS = config_entries.CONN_CLASS_LOCAL_POLL + CONNECTION_CLASS = CONN_CLASS_LOCAL_POLL def __init__(self): """Initialize.""" diff --git a/custom_components/stiebel_eltron_isg/coordinator.py b/custom_components/stiebel_eltron_isg/coordinator.py index a00d132..8f3e600 100644 --- a/custom_components/stiebel_eltron_isg/coordinator.py +++ b/custom_components/stiebel_eltron_isg/coordinator.py @@ -47,7 +47,7 @@ def __init__( self._client: AsyncModbusTcpClient = AsyncModbusTcpClient(host=host, port=port) self._lock = asyncio.Lock() self._scan_interval = timedelta(seconds=scan_interval) - self.platforms = [] + self.platforms: list = [] super().__init__(hass, _LOGGER, name=name, update_interval=self._scan_interval) diff --git a/custom_components/stiebel_eltron_isg/diagnostics.py b/custom_components/stiebel_eltron_isg/diagnostics.py index 76a3be2..db1d1f8 100644 --- a/custom_components/stiebel_eltron_isg/diagnostics.py +++ b/custom_components/stiebel_eltron_isg/diagnostics.py @@ -12,8 +12,8 @@ StiebelEltronISGIntegrationConfigEntry, ) -CONFIG_FIELDS_TO_REDACT = [] -DATA_FIELDS_TO_REDACT = [] +CONFIG_FIELDS_TO_REDACT: list = [] +DATA_FIELDS_TO_REDACT: list = [] async def async_get_config_entry_diagnostics( diff --git a/custom_components/stiebel_eltron_isg/lwz_coordinator.py b/custom_components/stiebel_eltron_isg/lwz_coordinator.py index 86208eb..bb48193 100644 --- a/custom_components/stiebel_eltron_isg/lwz_coordinator.py +++ b/custom_components/stiebel_eltron_isg/lwz_coordinator.py @@ -157,7 +157,7 @@ async def read_modbus_system_state(self) -> dict: async def read_modbus_system_values(self) -> dict: """Read the system related values from the ISG.""" - result = {} + result: dict = {} inverter_data = await self.read_input_registers(slave=1, address=0, count=40) if not inverter_data.isError(): decoder = BinaryPayloadDecoder.fromRegisters( @@ -261,7 +261,7 @@ async def read_modbus_system_values(self) -> dict: async def read_modbus_system_paramter(self) -> dict: """Read the system paramters from the ISG.""" - result = {} + result: dict = {} inverter_data = await self.read_holding_registers( slave=1, address=1000, diff --git a/custom_components/stiebel_eltron_isg/switch.py b/custom_components/stiebel_eltron_isg/switch.py index c69c738..524867a 100644 --- a/custom_components/stiebel_eltron_isg/switch.py +++ b/custom_components/stiebel_eltron_isg/switch.py @@ -99,7 +99,7 @@ def is_on(self) -> bool: value = self.coordinator.data.get(self.entity_description.key) if value is not None: return self.coordinator.data.get(self.entity_description.key) != 0 - return None + return False async def async_turn_on(self, **kwargs: Any) -> None: """Turn the switch on.""" diff --git a/custom_components/stiebel_eltron_isg/wpm_coordinator.py b/custom_components/stiebel_eltron_isg/wpm_coordinator.py index 9c41411..8b34843 100644 --- a/custom_components/stiebel_eltron_isg/wpm_coordinator.py +++ b/custom_components/stiebel_eltron_isg/wpm_coordinator.py @@ -367,7 +367,7 @@ async def read_modbus_system_state(self) -> dict: # noqa: C901 async def read_modbus_system_values(self) -> dict: """Read the system related values from the ISG.""" - result = {} + result: dict = {} inverter_data = await self.read_input_registers(slave=1, address=500, count=112) if not inverter_data.isError(): decoder = BinaryPayloadDecoder.fromRegisters( @@ -870,9 +870,9 @@ async def set_data(self, key, value) -> None: elif key == COMFORT_TEMPERATURE_TARGET_HK3: await self.write_register(address=1550, value=int(value * 10), slave=1) elif key == ECO_TEMPERATURE_TARGET_HK3: - await self.write_register(address=1551, value=int(value * 10), slave=1) + await self.write_register(address=1551, value=int(value * 10), slave=1) elif key == HEATING_CURVE_RISE_HK3: - await self.write_register(address=1552, value=int(value * 100), slave=1) + await self.write_register(address=1552, value=int(value * 100), slave=1) elif key == DUALMODE_TEMPERATURE_HZG: await self.write_register(address=1508, value=int(value * 10), slave=1) elif key == COMFORT_WATER_TEMPERATURE_TARGET: diff --git a/pyproject.toml b/pyproject.toml index 618c576..a2bc195 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -84,3 +84,6 @@ keep-runtime-typing = true [tool.ruff.lint.mccabe] max-complexity = 25 + +[tool.mypy] +ignore_missing_imports = true \ No newline at end of file diff --git a/uv.lock b/uv.lock index c93cc13..b32488c 100644 --- a/uv.lock +++ b/uv.lock @@ -1838,7 +1838,7 @@ dev = [ requires-dist = [ { name = "colorlog", specifier = ">=6.9.0" }, { name = "homeassistant", specifier = ">=2024.11.0" }, - { name = "pymodbus", specifier = ">=3.7.0" }, + { name = "pymodbus", specifier = ">=3.6.9" }, { name = "pytest-homeassistant-custom-component", specifier = ">=0.13.182" }, ]