From 280ab683b8ff0da15479c9a6fce6fe5a1d11b9ca Mon Sep 17 00:00:00 2001 From: Andrew Jackson Date: Mon, 16 Dec 2024 13:35:20 +0000 Subject: [PATCH 1/3] Fix options flow handler and add HA version check --- .../hildebrand_glow_ihd_mqtt/__init__.py | 13 ++++++++++++- .../hildebrand_glow_ihd_mqtt/config_flow.py | 10 ---------- custom_components/hildebrand_glow_ihd_mqtt/const.py | 2 +- hacs.json | 2 +- 4 files changed, 14 insertions(+), 13 deletions(-) diff --git a/custom_components/hildebrand_glow_ihd_mqtt/__init__.py b/custom_components/hildebrand_glow_ihd_mqtt/__init__.py index d88c78d..0933379 100755 --- a/custom_components/hildebrand_glow_ihd_mqtt/__init__.py +++ b/custom_components/hildebrand_glow_ihd_mqtt/__init__.py @@ -1,8 +1,9 @@ """The hildebrand_glow_ihd_mqtt component.""" import logging +from awesomeversion.awesomeversion import AwesomeVersion from homeassistant.config_entries import ConfigEntry -from homeassistant.const import CONF_DEVICE_ID +from homeassistant.const import __version__ as HA_VERSION, CONF_DEVICE_ID # noqa: N812 from homeassistant.core import HomeAssistant from .const import ( @@ -11,6 +12,7 @@ CONF_TOPIC_PREFIX, DEFAULT_TOPIC_PREFIX, DOMAIN, + MIN_HA_VERSION, ) _LOGGER = logging.getLogger(__name__) @@ -20,6 +22,15 @@ async def async_setup(hass: HomeAssistant, config: dict): """Set up the Hildebrand Glow IHD MQTT integration.""" + if AwesomeVersion(HA_VERSION) < AwesomeVersion(MIN_HA_VERSION): # pragma: no cover + msg = ( + "This integration requires at least HomeAssistant version " + f" {MIN_HA_VERSION}, you are running version {HA_VERSION}." + " Please upgrade HomeAssistant to continue use of this integration." + ) + _LOGGER.critical(msg) + return False + if DOMAIN not in hass.data: hass.data[DOMAIN] = {} diff --git a/custom_components/hildebrand_glow_ihd_mqtt/config_flow.py b/custom_components/hildebrand_glow_ihd_mqtt/config_flow.py index c9267d4..7156d72 100755 --- a/custom_components/hildebrand_glow_ihd_mqtt/config_flow.py +++ b/custom_components/hildebrand_glow_ihd_mqtt/config_flow.py @@ -77,20 +77,10 @@ async def async_step_user(self, user_input=None): }), errors=errors ) - @staticmethod - @callback - def async_get_options_flow(config_entry): - """Get the options flow for this handler.""" - return HildebrandGlowIHDMQTTOptionsFlowHandler(config_entry) - class HildebrandGlowIHDMQTTOptionsFlowHandler(OptionsFlow): """Handle a option flow for HildebrandGlowIHDMQTT.""" - def __init__(self, config_entry: ConfigEntry) -> None: - """Initialize options flow.""" - self.config_entry = config_entry - async def async_step_init(self, user_input=None): """Handle options flow.""" if user_input is not None: diff --git a/custom_components/hildebrand_glow_ihd_mqtt/const.py b/custom_components/hildebrand_glow_ihd_mqtt/const.py index e1c50a6..94d7e43 100755 --- a/custom_components/hildebrand_glow_ihd_mqtt/const.py +++ b/custom_components/hildebrand_glow_ihd_mqtt/const.py @@ -3,7 +3,7 @@ from enum import Enum DOMAIN: Final = "hildebrand_glow_ihd" - +MIN_HA_VERSION = "2024.12" ATTR_NAME = "name" ATTR_ACTIVITY = "activity" diff --git a/hacs.json b/hacs.json index 39c5cdb..bcbe358 100644 --- a/hacs.json +++ b/hacs.json @@ -3,5 +3,5 @@ "render_readme": true, "domains": ["sensor"], "country": ["GB"], - "homeassistant": "2021.9.0" + "homeassistant": "2024.12.0" } \ No newline at end of file From 4b4ac476930520ab869e8ea33b7381423d526e23 Mon Sep 17 00:00:00 2001 From: Andrew Jackson Date: Mon, 16 Dec 2024 13:36:20 +0000 Subject: [PATCH 2/3] Remove unused imports --- custom_components/hildebrand_glow_ihd_mqtt/config_flow.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/custom_components/hildebrand_glow_ihd_mqtt/config_flow.py b/custom_components/hildebrand_glow_ihd_mqtt/config_flow.py index 7156d72..f5bdfbc 100755 --- a/custom_components/hildebrand_glow_ihd_mqtt/config_flow.py +++ b/custom_components/hildebrand_glow_ihd_mqtt/config_flow.py @@ -5,12 +5,10 @@ from homeassistant.config_entries import ( ConfigFlow, - ConfigEntry, CONN_CLASS_LOCAL_PUSH, OptionsFlow, ) from homeassistant.const import CONF_DEVICE_ID -from homeassistant.core import callback from homeassistant.helpers.selector import ( SelectSelector, SelectSelectorConfig, From 86d226d98a1ac30525a1203ac7a7c3f64d69c885 Mon Sep 17 00:00:00 2001 From: Andrew Jackson Date: Tue, 17 Dec 2024 10:04:28 +0000 Subject: [PATCH 3/3] Fixes --- custom_components/hildebrand_glow_ihd_mqtt/config_flow.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/custom_components/hildebrand_glow_ihd_mqtt/config_flow.py b/custom_components/hildebrand_glow_ihd_mqtt/config_flow.py index f5bdfbc..670411a 100755 --- a/custom_components/hildebrand_glow_ihd_mqtt/config_flow.py +++ b/custom_components/hildebrand_glow_ihd_mqtt/config_flow.py @@ -9,6 +9,7 @@ OptionsFlow, ) from homeassistant.const import CONF_DEVICE_ID +from homeassistant.core import callback from homeassistant.helpers.selector import ( SelectSelector, SelectSelectorConfig, @@ -75,6 +76,11 @@ async def async_step_user(self, user_input=None): }), errors=errors ) + @staticmethod + @callback + def async_get_options_flow(config_entry): + """Get the options flow for this handler.""" + return HildebrandGlowIHDMQTTOptionsFlowHandler() class HildebrandGlowIHDMQTTOptionsFlowHandler(OptionsFlow): """Handle a option flow for HildebrandGlowIHDMQTT."""