Bump datapoint to 0.9.9 + re-enable Met Office Integration (#110206)

pull/110484/head
DustyArmstrong 2024-02-13 16:24:08 +00:00 committed by GitHub
parent 43bd05ba82
commit 3bf6d525fb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 19 additions and 31 deletions

View File

@ -4,9 +4,10 @@ from __future__ import annotations
import asyncio
import logging
import re
import sys
from typing import Any
import datapoint
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import (
CONF_API_KEY,
@ -16,7 +17,7 @@ from homeassistant.const import (
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
@ -34,9 +35,6 @@ from .const import (
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]
@ -44,10 +42,6 @@ PLATFORMS = [Platform.SENSOR, Platform.WEATHER]
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]

View File

@ -2,12 +2,10 @@
from __future__ import annotations
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

View File

@ -2,7 +2,9 @@
from __future__ import annotations
import logging
import sys
import datapoint
from datapoint.Site import Site
from homeassistant.helpers.update_coordinator import UpdateFailed
from homeassistant.util.dt import utcnow
@ -10,11 +12,6 @@ from homeassistant.util.dt import utcnow
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__)
@ -34,7 +31,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

View File

@ -3,9 +3,8 @@
"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"],
"requirements": ["datapoint==0.9.8;python_version<'3.12'"]
"requirements": ["datapoint==0.9.9"]
}

View File

@ -251,6 +251,6 @@ class MetOfficeCurrentSensor(
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,
}

View File

@ -680,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

View File

@ -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

View File

@ -1,15 +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"]
@pytest.fixture
def mock_simple_manager_fail():