Bump datapoint to 0.9.9 + re-enable Met Office Integration (#110206)
This commit is contained in:
parent
43bd05ba82
commit
3bf6d525fb
8 changed files with 19 additions and 31 deletions
|
@ -4,9 +4,10 @@ from __future__ import annotations
|
||||||
import asyncio
|
import asyncio
|
||||||
import logging
|
import logging
|
||||||
import re
|
import re
|
||||||
import sys
|
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
|
import datapoint
|
||||||
|
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
CONF_API_KEY,
|
CONF_API_KEY,
|
||||||
|
@ -16,7 +17,7 @@ from homeassistant.const import (
|
||||||
Platform,
|
Platform,
|
||||||
)
|
)
|
||||||
from homeassistant.core import HomeAssistant, callback
|
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 import device_registry as dr, entity_registry as er
|
||||||
from homeassistant.helpers.device_registry import DeviceInfo
|
from homeassistant.helpers.device_registry import DeviceInfo
|
||||||
from homeassistant.helpers.update_coordinator import TimestampDataUpdateCoordinator
|
from homeassistant.helpers.update_coordinator import TimestampDataUpdateCoordinator
|
||||||
|
@ -34,9 +35,6 @@ from .const import (
|
||||||
from .data import MetOfficeData
|
from .data import MetOfficeData
|
||||||
from .helpers import fetch_data, fetch_site
|
from .helpers import fetch_data, fetch_site
|
||||||
|
|
||||||
if sys.version_info < (3, 12):
|
|
||||||
import datapoint
|
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
PLATFORMS = [Platform.SENSOR, Platform.WEATHER]
|
PLATFORMS = [Platform.SENSOR, Platform.WEATHER]
|
||||||
|
@ -44,10 +42,6 @@ PLATFORMS = [Platform.SENSOR, Platform.WEATHER]
|
||||||
|
|
||||||
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||||
"""Set up a Met Office entry."""
|
"""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]
|
latitude = entry.data[CONF_LATITUDE]
|
||||||
longitude = entry.data[CONF_LONGITUDE]
|
longitude = entry.data[CONF_LONGITUDE]
|
||||||
|
|
|
@ -2,12 +2,10 @@
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
import sys
|
|
||||||
|
|
||||||
if sys.version_info < (3, 12):
|
from datapoint.Forecast import Forecast
|
||||||
from datapoint.Forecast import Forecast
|
from datapoint.Site import Site
|
||||||
from datapoint.Site import Site
|
from datapoint.Timestep import Timestep
|
||||||
from datapoint.Timestep import Timestep
|
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
|
|
|
@ -2,7 +2,9 @@
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
import sys
|
|
||||||
|
import datapoint
|
||||||
|
from datapoint.Site import Site
|
||||||
|
|
||||||
from homeassistant.helpers.update_coordinator import UpdateFailed
|
from homeassistant.helpers.update_coordinator import UpdateFailed
|
||||||
from homeassistant.util.dt import utcnow
|
from homeassistant.util.dt import utcnow
|
||||||
|
@ -10,11 +12,6 @@ from homeassistant.util.dt import utcnow
|
||||||
from .const import MODE_3HOURLY
|
from .const import MODE_3HOURLY
|
||||||
from .data import MetOfficeData
|
from .data import MetOfficeData
|
||||||
|
|
||||||
if sys.version_info < (3, 12):
|
|
||||||
import datapoint
|
|
||||||
from datapoint.Site import Site
|
|
||||||
|
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
@ -34,7 +31,7 @@ def fetch_site(
|
||||||
def fetch_data(connection: datapoint.Manager, site: Site, mode: str) -> MetOfficeData:
|
def fetch_data(connection: datapoint.Manager, site: Site, mode: str) -> MetOfficeData:
|
||||||
"""Fetch weather and forecast from Datapoint API."""
|
"""Fetch weather and forecast from Datapoint API."""
|
||||||
try:
|
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:
|
except (ValueError, datapoint.exceptions.APIException) as err:
|
||||||
_LOGGER.error("Check Met Office connection: %s", err.args)
|
_LOGGER.error("Check Met Office connection: %s", err.args)
|
||||||
raise UpdateFailed from err
|
raise UpdateFailed from err
|
||||||
|
|
|
@ -3,9 +3,8 @@
|
||||||
"name": "Met Office",
|
"name": "Met Office",
|
||||||
"codeowners": ["@MrHarcombe", "@avee87"],
|
"codeowners": ["@MrHarcombe", "@avee87"],
|
||||||
"config_flow": true,
|
"config_flow": true,
|
||||||
"disabled": "Integration library not compatible with Python 3.12",
|
|
||||||
"documentation": "https://www.home-assistant.io/integrations/metoffice",
|
"documentation": "https://www.home-assistant.io/integrations/metoffice",
|
||||||
"iot_class": "cloud_polling",
|
"iot_class": "cloud_polling",
|
||||||
"loggers": ["datapoint"],
|
"loggers": ["datapoint"],
|
||||||
"requirements": ["datapoint==0.9.8;python_version<'3.12'"]
|
"requirements": ["datapoint==0.9.9"]
|
||||||
}
|
}
|
||||||
|
|
|
@ -251,6 +251,6 @@ class MetOfficeCurrentSensor(
|
||||||
return {
|
return {
|
||||||
ATTR_LAST_UPDATE: self.coordinator.data.now.date,
|
ATTR_LAST_UPDATE: self.coordinator.data.now.date,
|
||||||
ATTR_SENSOR_ID: self.entity_description.key,
|
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,
|
ATTR_SITE_NAME: self.coordinator.data.site.name,
|
||||||
}
|
}
|
||||||
|
|
|
@ -680,6 +680,9 @@ crownstone-uart==2.1.0
|
||||||
# homeassistant.components.datadog
|
# homeassistant.components.datadog
|
||||||
datadog==0.15.0
|
datadog==0.15.0
|
||||||
|
|
||||||
|
# homeassistant.components.metoffice
|
||||||
|
datapoint==0.9.9
|
||||||
|
|
||||||
# homeassistant.components.bluetooth
|
# homeassistant.components.bluetooth
|
||||||
dbus-fast==2.21.1
|
dbus-fast==2.21.1
|
||||||
|
|
||||||
|
|
|
@ -561,6 +561,9 @@ crownstone-uart==2.1.0
|
||||||
# homeassistant.components.datadog
|
# homeassistant.components.datadog
|
||||||
datadog==0.15.0
|
datadog==0.15.0
|
||||||
|
|
||||||
|
# homeassistant.components.metoffice
|
||||||
|
datapoint==0.9.9
|
||||||
|
|
||||||
# homeassistant.components.bluetooth
|
# homeassistant.components.bluetooth
|
||||||
dbus-fast==2.21.1
|
dbus-fast==2.21.1
|
||||||
|
|
||||||
|
|
|
@ -1,15 +1,9 @@
|
||||||
"""Fixtures for Met Office weather integration tests."""
|
"""Fixtures for Met Office weather integration tests."""
|
||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
|
|
||||||
|
from datapoint.exceptions import APIException
|
||||||
import pytest
|
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
|
@pytest.fixture
|
||||||
def mock_simple_manager_fail():
|
def mock_simple_manager_fail():
|
||||||
|
|
Loading…
Add table
Reference in a new issue