From 87f0cdd8710734c0054d1a6a1b69840924718581 Mon Sep 17 00:00:00 2001 From: DustyArmstrong Date: Sat, 10 Feb 2024 16:36:48 +0000 Subject: [PATCH 01/16] Update helpers.py Update helpers.py to reflect changes made to variable in https://github.com/EJEP/datapoint-python/blob/master/CHANGELOG.md --- homeassistant/components/metoffice/helpers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homeassistant/components/metoffice/helpers.py b/homeassistant/components/metoffice/helpers.py index 389462d573a2..2dad55cf9130 100644 --- a/homeassistant/components/metoffice/helpers.py +++ b/homeassistant/components/metoffice/helpers.py @@ -34,7 +34,7 @@ def fetch_site( def fetch_data(connection: datapoint.Manager, site: Site, mode: str) -> MetOfficeData: """Fetch weather and forecast from Datapoint API.""" try: - forecast = connection.get_forecast_for_site(site.id, mode) + forecast = connection.get_forecast_for_site(site.location_id, mode) except (ValueError, datapoint.exceptions.APIException) as err: _LOGGER.error("Check Met Office connection: %s", err.args) raise UpdateFailed from err From 76537277e98ce01524b604660b54a4cebab7f680 Mon Sep 17 00:00:00 2001 From: DustyArmstrong Date: Sat, 10 Feb 2024 16:37:40 +0000 Subject: [PATCH 02/16] Update sensor.py Update sensor.py to reflect changes made to variables as mentioned in https://github.com/EJEP/datapoint-python/blob/master/CHANGELOG.md --- homeassistant/components/metoffice/sensor.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homeassistant/components/metoffice/sensor.py b/homeassistant/components/metoffice/sensor.py index 371c396a8291..84a51a0d5843 100644 --- a/homeassistant/components/metoffice/sensor.py +++ b/homeassistant/components/metoffice/sensor.py @@ -251,6 +251,6 @@ def extra_state_attributes(self) -> dict[str, Any]: return { ATTR_LAST_UPDATE: self.coordinator.data.now.date, ATTR_SENSOR_ID: self.entity_description.key, - ATTR_SITE_ID: self.coordinator.data.site.id, + ATTR_SITE_ID: self.coordinator.data.site.location_id, ATTR_SITE_NAME: self.coordinator.data.site.name, } From 1f7bb3a2c0e707b264984ca2c834faf25d1aa33b Mon Sep 17 00:00:00 2001 From: DustyArmstrong Date: Sat, 10 Feb 2024 17:03:36 +0000 Subject: [PATCH 03/16] Update __init__.py Update __init__.py to remove reference to Python 3.12 requirement. --- homeassistant/components/metoffice/__init__.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/homeassistant/components/metoffice/__init__.py b/homeassistant/components/metoffice/__init__.py index e00215f60736..81020d94e1a5 100644 --- a/homeassistant/components/metoffice/__init__.py +++ b/homeassistant/components/metoffice/__init__.py @@ -5,6 +5,7 @@ import logging import re import sys +import datapoint from typing import Any from homeassistant.config_entries import ConfigEntry @@ -34,9 +35,6 @@ from .data import MetOfficeData from .helpers import fetch_data, fetch_site -if sys.version_info < (3, 12): - import datapoint - _LOGGER = logging.getLogger(__name__) PLATFORMS = [Platform.SENSOR, Platform.WEATHER] From ab57c467265044c0e2e719418f2dbbecee408c01 Mon Sep 17 00:00:00 2001 From: DustyArmstrong Date: Sat, 10 Feb 2024 17:47:33 +0000 Subject: [PATCH 04/16] Update helpers.py Update helpers.py to remove reference to <3.12 --- homeassistant/components/metoffice/helpers.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/homeassistant/components/metoffice/helpers.py b/homeassistant/components/metoffice/helpers.py index 2dad55cf9130..692c22a9c982 100644 --- a/homeassistant/components/metoffice/helpers.py +++ b/homeassistant/components/metoffice/helpers.py @@ -7,14 +7,12 @@ from homeassistant.helpers.update_coordinator import UpdateFailed from homeassistant.util.dt import utcnow +import datapoint +from datapoint.Site import Site + from .const import MODE_3HOURLY from .data import MetOfficeData -if sys.version_info < (3, 12): - import datapoint - from datapoint.Site import Site - - _LOGGER = logging.getLogger(__name__) From 2991b6a5aff9473e1b6237646dbce019d68a6ecb Mon Sep 17 00:00:00 2001 From: DustyArmstrong Date: Sat, 10 Feb 2024 17:48:48 +0000 Subject: [PATCH 05/16] Update data.py Updated data.py to remove references to Python < 3.12 though having the original lines did not actually impact functionality --- homeassistant/components/metoffice/data.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/homeassistant/components/metoffice/data.py b/homeassistant/components/metoffice/data.py index 8512dd4c7a65..060e080ec8c5 100644 --- a/homeassistant/components/metoffice/data.py +++ b/homeassistant/components/metoffice/data.py @@ -4,10 +4,9 @@ from dataclasses import dataclass import sys -if sys.version_info < (3, 12): - from datapoint.Forecast import Forecast - from datapoint.Site import Site - from datapoint.Timestep import Timestep +from datapoint.Forecast import Forecast +from datapoint.Site import Site +from datapoint.Timestep import Timestep @dataclass From c372f3145cfc7e86ee1c68446c14bb8cc1225f79 Mon Sep 17 00:00:00 2001 From: DustyArmstrong Date: Sat, 10 Feb 2024 18:26:37 +0000 Subject: [PATCH 06/16] Update manifest.json Update for v 0.9.9 --- homeassistant/components/metoffice/manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homeassistant/components/metoffice/manifest.json b/homeassistant/components/metoffice/manifest.json index 401f2c9d2652..a247e0559c3f 100644 --- a/homeassistant/components/metoffice/manifest.json +++ b/homeassistant/components/metoffice/manifest.json @@ -7,5 +7,5 @@ "documentation": "https://www.home-assistant.io/integrations/metoffice", "iot_class": "cloud_polling", "loggers": ["datapoint"], - "requirements": ["datapoint==0.9.8;python_version<'3.12'"] + "requirements": ["datapoint==0.9.9;python_version<'3.12'"] } From 3c5c40665f8fafb663c2ea1ea2c267d85c976565 Mon Sep 17 00:00:00 2001 From: DustyArmstrong Date: Sat, 10 Feb 2024 18:32:17 +0000 Subject: [PATCH 07/16] Update manifest.json --- homeassistant/components/metoffice/manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homeassistant/components/metoffice/manifest.json b/homeassistant/components/metoffice/manifest.json index a247e0559c3f..46411865267b 100644 --- a/homeassistant/components/metoffice/manifest.json +++ b/homeassistant/components/metoffice/manifest.json @@ -7,5 +7,5 @@ "documentation": "https://www.home-assistant.io/integrations/metoffice", "iot_class": "cloud_polling", "loggers": ["datapoint"], - "requirements": ["datapoint==0.9.9;python_version<'3.12'"] + "requirements": ["datapoint==0.9.9"] } From e1588275e2b3fe648ba3fda44f732307870bb277 Mon Sep 17 00:00:00 2001 From: DustyArmstrong Date: Sat, 10 Feb 2024 19:48:35 +0000 Subject: [PATCH 08/16] Update manifest.json Remove disabled tag --- homeassistant/components/metoffice/manifest.json | 1 - 1 file changed, 1 deletion(-) diff --git a/homeassistant/components/metoffice/manifest.json b/homeassistant/components/metoffice/manifest.json index 46411865267b..17643d7e0615 100644 --- a/homeassistant/components/metoffice/manifest.json +++ b/homeassistant/components/metoffice/manifest.json @@ -3,7 +3,6 @@ "name": "Met Office", "codeowners": ["@MrHarcombe", "@avee87"], "config_flow": true, - "disabled": "Integration library not compatible with Python 3.12", "documentation": "https://www.home-assistant.io/integrations/metoffice", "iot_class": "cloud_polling", "loggers": ["datapoint"], From 5dcfbb8f71cc99ca161ee933125a3cf37e70f0aa Mon Sep 17 00:00:00 2001 From: DustyArmstrong Date: Sat, 10 Feb 2024 21:08:23 +0000 Subject: [PATCH 09/16] Bump datapoint to 0.9.9 Bump datapoint dependency following fix https://github.com/EJEP/datapoint-python/issues/183 --- requirements_all.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/requirements_all.txt b/requirements_all.txt index d87beb5cc230..d9c613e70656 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -71,7 +71,9 @@ PyMVGLive==1.1.4 # homeassistant.components.met_eireann PyMetEireann==2021.8.0 -# homeassistant.components.met +# homeassistant.components.metoffice +datapoint==0.9.9 + # homeassistant.components.norway_air PyMetno==0.11.0 From f3a99e52b99638cec4b943de86ee6dd840339805 Mon Sep 17 00:00:00 2001 From: DustyArmstrong Date: Sat, 10 Feb 2024 21:11:38 +0000 Subject: [PATCH 10/16] Bump datapoint to 0.9.9 --- requirements_all.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/requirements_all.txt b/requirements_all.txt index d9c613e70656..7a0f94d9cd61 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -71,6 +71,8 @@ PyMVGLive==1.1.4 # homeassistant.components.met_eireann PyMetEireann==2021.8.0 +# homeassistant.components.met + # homeassistant.components.metoffice datapoint==0.9.9 From 9eb11dc3cbc0a437fa60c118f36100c266356b32 Mon Sep 17 00:00:00 2001 From: DustyArmstrong Date: Sat, 10 Feb 2024 22:05:34 +0000 Subject: [PATCH 11/16] Bump datapoint to 0.9.9 Generated with requirements script --- requirements_all.txt | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/requirements_all.txt b/requirements_all.txt index 7a0f94d9cd61..6beba768b647 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -72,10 +72,6 @@ PyMVGLive==1.1.4 PyMetEireann==2021.8.0 # homeassistant.components.met - -# homeassistant.components.metoffice -datapoint==0.9.9 - # homeassistant.components.norway_air PyMetno==0.11.0 @@ -684,6 +680,9 @@ crownstone-uart==2.1.0 # homeassistant.components.datadog datadog==0.15.0 +# homeassistant.components.metoffice +datapoint==0.9.9 + # homeassistant.components.bluetooth dbus-fast==2.21.1 From 141b9171cf31764cbf432718e7c8b80aeda8a8f4 Mon Sep 17 00:00:00 2001 From: DustyArmstrong Date: Mon, 12 Feb 2024 14:12:30 +0000 Subject: [PATCH 12/16] Fixes for CI passes --- homeassistant/components/metoffice/__init__.py | 3 ++- homeassistant/components/metoffice/data.py | 1 - homeassistant/components/metoffice/helpers.py | 7 +++---- requirements_test_all.txt | 3 +++ 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/homeassistant/components/metoffice/__init__.py b/homeassistant/components/metoffice/__init__.py index 81020d94e1a5..2a4e64e4caad 100644 --- a/homeassistant/components/metoffice/__init__.py +++ b/homeassistant/components/metoffice/__init__.py @@ -5,9 +5,10 @@ import logging import re import sys -import datapoint from typing import Any +import datapoint + from homeassistant.config_entries import ConfigEntry from homeassistant.const import ( CONF_API_KEY, diff --git a/homeassistant/components/metoffice/data.py b/homeassistant/components/metoffice/data.py index 060e080ec8c5..c6bb2b4c01bc 100644 --- a/homeassistant/components/metoffice/data.py +++ b/homeassistant/components/metoffice/data.py @@ -2,7 +2,6 @@ from __future__ import annotations from dataclasses import dataclass -import sys from datapoint.Forecast import Forecast from datapoint.Site import Site diff --git a/homeassistant/components/metoffice/helpers.py b/homeassistant/components/metoffice/helpers.py index 692c22a9c982..5b698bf19da1 100644 --- a/homeassistant/components/metoffice/helpers.py +++ b/homeassistant/components/metoffice/helpers.py @@ -2,14 +2,13 @@ from __future__ import annotations import logging -import sys - -from homeassistant.helpers.update_coordinator import UpdateFailed -from homeassistant.util.dt import utcnow import datapoint from datapoint.Site import Site +from homeassistant.helpers.update_coordinator import UpdateFailed +from homeassistant.util.dt import utcnow + from .const import MODE_3HOURLY from .data import MetOfficeData diff --git a/requirements_test_all.txt b/requirements_test_all.txt index e48d31cc91cb..6c0dbb8459f2 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -561,6 +561,9 @@ crownstone-uart==2.1.0 # homeassistant.components.datadog datadog==0.15.0 +# homeassistant.components.metoffice +datapoint==0.9.9 + # homeassistant.components.bluetooth dbus-fast==2.21.1 From a8067a6639fbb3dbc895fcc8d198860768e9ec01 Mon Sep 17 00:00:00 2001 From: DustyArmstrong Date: Tue, 13 Feb 2024 09:04:42 +0000 Subject: [PATCH 13/16] Re-enable tests! --- tests/components/metoffice/conftest.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/tests/components/metoffice/conftest.py b/tests/components/metoffice/conftest.py index 117bfe417e32..0f55bece8194 100644 --- a/tests/components/metoffice/conftest.py +++ b/tests/components/metoffice/conftest.py @@ -1,13 +1,9 @@ """Fixtures for Met Office weather integration tests.""" from unittest.mock import patch +from datapoint.exceptions import APIException import pytest -# All tests are marked as disabled, as the integration is disabled in the -# integration manifest. `datapoint` isn't compatible with Python 3.12 -# -# from datapoint.exceptions import APIException -APIException = Exception collect_ignore_glob = ["test_*.py"] From 06bc78045974a059cc8960337788c846c379f30a Mon Sep 17 00:00:00 2001 From: DustyArmstrong Date: Tue, 13 Feb 2024 09:28:35 +0000 Subject: [PATCH 14/16] Removed collect_ignore_glob --- tests/components/metoffice/conftest.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/components/metoffice/conftest.py b/tests/components/metoffice/conftest.py index 0f55bece8194..b1d1c9f508e2 100644 --- a/tests/components/metoffice/conftest.py +++ b/tests/components/metoffice/conftest.py @@ -4,8 +4,6 @@ from datapoint.exceptions import APIException import pytest -collect_ignore_glob = ["test_*.py"] - @pytest.fixture def mock_simple_manager_fail(): From 2a2ef31e303e353232a9c929eb72cc18bdf42532 Mon Sep 17 00:00:00 2001 From: DustyArmstrong Date: Tue, 13 Feb 2024 11:30:35 +0000 Subject: [PATCH 15/16] Removed if block for Python 3.12 --- homeassistant/components/metoffice/__init__.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/homeassistant/components/metoffice/__init__.py b/homeassistant/components/metoffice/__init__.py index 2a4e64e4caad..4afd9c27c404 100644 --- a/homeassistant/components/metoffice/__init__.py +++ b/homeassistant/components/metoffice/__init__.py @@ -43,10 +43,6 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: """Set up a Met Office entry.""" - if sys.version_info >= (3, 12): - raise HomeAssistantError( - "Met Office is not supported on Python 3.12. Please use Python 3.11." - ) latitude = entry.data[CONF_LATITUDE] longitude = entry.data[CONF_LONGITUDE] From c4043c3917b41f30274b27fced29e67efe7fb8a2 Mon Sep 17 00:00:00 2001 From: DustyArmstrong Date: Tue, 13 Feb 2024 13:45:18 +0000 Subject: [PATCH 16/16] Re-ruffed code --- homeassistant/components/metoffice/__init__.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/homeassistant/components/metoffice/__init__.py b/homeassistant/components/metoffice/__init__.py index 4afd9c27c404..a658de9a024e 100644 --- a/homeassistant/components/metoffice/__init__.py +++ b/homeassistant/components/metoffice/__init__.py @@ -4,7 +4,6 @@ import asyncio import logging import re -import sys from typing import Any import datapoint @@ -18,7 +17,7 @@ Platform, ) from homeassistant.core import HomeAssistant, callback -from homeassistant.exceptions import ConfigEntryNotReady, HomeAssistantError +from homeassistant.exceptions import ConfigEntryNotReady from homeassistant.helpers import device_registry as dr, entity_registry as er from homeassistant.helpers.device_registry import DeviceInfo from homeassistant.helpers.update_coordinator import TimestampDataUpdateCoordinator