mirror of
https://github.com/home-assistant/core.git
synced 2025-07-15 09:17:10 +00:00
Bump pyopenweathermap to 0.2.2 and remove deprecated API version v2.5 (#139599)
* Bump pyopenweathermap * Remove deprecated API mode v2.5
This commit is contained in:
parent
077ff63b38
commit
4a7fd89abd
@ -11,7 +11,7 @@ from homeassistant.config_entries import ConfigEntry
|
|||||||
from homeassistant.const import CONF_API_KEY, CONF_LANGUAGE, CONF_MODE, CONF_NAME
|
from homeassistant.const import CONF_API_KEY, CONF_LANGUAGE, CONF_MODE, CONF_NAME
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
|
|
||||||
from .const import CONFIG_FLOW_VERSION, OWM_MODE_V25, PLATFORMS
|
from .const import CONFIG_FLOW_VERSION, DEFAULT_OWM_MODE, OWM_MODES, PLATFORMS
|
||||||
from .coordinator import WeatherUpdateCoordinator
|
from .coordinator import WeatherUpdateCoordinator
|
||||||
from .repairs import async_create_issue, async_delete_issue
|
from .repairs import async_create_issue, async_delete_issue
|
||||||
from .utils import build_data_and_options
|
from .utils import build_data_and_options
|
||||||
@ -39,7 +39,7 @@ async def async_setup_entry(
|
|||||||
language = entry.options[CONF_LANGUAGE]
|
language = entry.options[CONF_LANGUAGE]
|
||||||
mode = entry.options[CONF_MODE]
|
mode = entry.options[CONF_MODE]
|
||||||
|
|
||||||
if mode == OWM_MODE_V25:
|
if mode not in OWM_MODES:
|
||||||
async_create_issue(hass, entry.entry_id)
|
async_create_issue(hass, entry.entry_id)
|
||||||
else:
|
else:
|
||||||
async_delete_issue(hass, entry.entry_id)
|
async_delete_issue(hass, entry.entry_id)
|
||||||
@ -70,7 +70,7 @@ async def async_migrate_entry(
|
|||||||
_LOGGER.debug("Migrating OpenWeatherMap entry from version %s", version)
|
_LOGGER.debug("Migrating OpenWeatherMap entry from version %s", version)
|
||||||
|
|
||||||
if version < 5:
|
if version < 5:
|
||||||
combined_data = {**data, **options, CONF_MODE: OWM_MODE_V25}
|
combined_data = {**data, **options, CONF_MODE: DEFAULT_OWM_MODE}
|
||||||
new_data, new_options = build_data_and_options(combined_data)
|
new_data, new_options = build_data_and_options(combined_data)
|
||||||
config_entries.async_update_entry(
|
config_entries.async_update_entry(
|
||||||
entry,
|
entry,
|
||||||
|
@ -62,10 +62,8 @@ FORECAST_MODE_ONECALL_DAILY = "onecall_daily"
|
|||||||
OWM_MODE_FREE_CURRENT = "current"
|
OWM_MODE_FREE_CURRENT = "current"
|
||||||
OWM_MODE_FREE_FORECAST = "forecast"
|
OWM_MODE_FREE_FORECAST = "forecast"
|
||||||
OWM_MODE_V30 = "v3.0"
|
OWM_MODE_V30 = "v3.0"
|
||||||
OWM_MODE_V25 = "v2.5"
|
|
||||||
OWM_MODES = [
|
OWM_MODES = [
|
||||||
OWM_MODE_V30,
|
OWM_MODE_V30,
|
||||||
OWM_MODE_V25,
|
|
||||||
OWM_MODE_FREE_CURRENT,
|
OWM_MODE_FREE_CURRENT,
|
||||||
OWM_MODE_FREE_FORECAST,
|
OWM_MODE_FREE_FORECAST,
|
||||||
]
|
]
|
||||||
|
@ -6,5 +6,5 @@
|
|||||||
"documentation": "https://www.home-assistant.io/integrations/openweathermap",
|
"documentation": "https://www.home-assistant.io/integrations/openweathermap",
|
||||||
"iot_class": "cloud_polling",
|
"iot_class": "cloud_polling",
|
||||||
"loggers": ["pyopenweathermap"],
|
"loggers": ["pyopenweathermap"],
|
||||||
"requirements": ["pyopenweathermap==0.2.1"]
|
"requirements": ["pyopenweathermap==0.2.2"]
|
||||||
}
|
}
|
||||||
|
@ -42,7 +42,6 @@ from .const import (
|
|||||||
DOMAIN,
|
DOMAIN,
|
||||||
MANUFACTURER,
|
MANUFACTURER,
|
||||||
OWM_MODE_FREE_FORECAST,
|
OWM_MODE_FREE_FORECAST,
|
||||||
OWM_MODE_V25,
|
|
||||||
OWM_MODE_V30,
|
OWM_MODE_V30,
|
||||||
)
|
)
|
||||||
from .coordinator import WeatherUpdateCoordinator
|
from .coordinator import WeatherUpdateCoordinator
|
||||||
@ -106,7 +105,7 @@ class OpenWeatherMapWeather(SingleCoordinatorWeatherEntity[WeatherUpdateCoordina
|
|||||||
)
|
)
|
||||||
self.mode = mode
|
self.mode = mode
|
||||||
|
|
||||||
if mode in (OWM_MODE_V30, OWM_MODE_V25):
|
if mode == OWM_MODE_V30:
|
||||||
self._attr_supported_features = (
|
self._attr_supported_features = (
|
||||||
WeatherEntityFeature.FORECAST_DAILY
|
WeatherEntityFeature.FORECAST_DAILY
|
||||||
| WeatherEntityFeature.FORECAST_HOURLY
|
| WeatherEntityFeature.FORECAST_HOURLY
|
||||||
|
2
requirements_all.txt
generated
2
requirements_all.txt
generated
@ -2179,7 +2179,7 @@ pyombi==0.1.10
|
|||||||
pyopenuv==2023.02.0
|
pyopenuv==2023.02.0
|
||||||
|
|
||||||
# homeassistant.components.openweathermap
|
# homeassistant.components.openweathermap
|
||||||
pyopenweathermap==0.2.1
|
pyopenweathermap==0.2.2
|
||||||
|
|
||||||
# homeassistant.components.opnsense
|
# homeassistant.components.opnsense
|
||||||
pyopnsense==0.4.0
|
pyopnsense==0.4.0
|
||||||
|
2
requirements_test_all.txt
generated
2
requirements_test_all.txt
generated
@ -1778,7 +1778,7 @@ pyoctoprintapi==0.1.12
|
|||||||
pyopenuv==2023.02.0
|
pyopenuv==2023.02.0
|
||||||
|
|
||||||
# homeassistant.components.openweathermap
|
# homeassistant.components.openweathermap
|
||||||
pyopenweathermap==0.2.1
|
pyopenweathermap==0.2.2
|
||||||
|
|
||||||
# homeassistant.components.opnsense
|
# homeassistant.components.opnsense
|
||||||
pyopnsense==0.4.0
|
pyopnsense==0.4.0
|
||||||
|
@ -6,7 +6,7 @@ from syrupy import SnapshotAssertion
|
|||||||
from homeassistant.components.openweathermap.const import (
|
from homeassistant.components.openweathermap.const import (
|
||||||
DEFAULT_LANGUAGE,
|
DEFAULT_LANGUAGE,
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
OWM_MODE_V25,
|
OWM_MODE_FREE_CURRENT,
|
||||||
OWM_MODE_V30,
|
OWM_MODE_V30,
|
||||||
)
|
)
|
||||||
from homeassistant.components.openweathermap.weather import SERVICE_GET_MINUTE_FORECAST
|
from homeassistant.components.openweathermap.weather import SERVICE_GET_MINUTE_FORECAST
|
||||||
@ -52,9 +52,9 @@ def mock_config_entry(mode: str) -> MockConfigEntry:
|
|||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def mock_config_entry_v25() -> MockConfigEntry:
|
def mock_config_entry_free_current() -> MockConfigEntry:
|
||||||
"""Create a mock OpenWeatherMap v2.5 config entry."""
|
"""Create a mock OpenWeatherMap FREE_CURRENT config entry."""
|
||||||
return mock_config_entry(OWM_MODE_V25)
|
return mock_config_entry(OWM_MODE_FREE_CURRENT)
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
@ -97,15 +97,15 @@ async def test_get_minute_forecast(
|
|||||||
|
|
||||||
|
|
||||||
@patch(
|
@patch(
|
||||||
"pyopenweathermap.client.onecall_client.OWMOneCallClient.get_weather",
|
"pyopenweathermap.client.free_client.OWMFreeClient.get_weather",
|
||||||
AsyncMock(return_value=static_weather_report),
|
AsyncMock(return_value=static_weather_report),
|
||||||
)
|
)
|
||||||
async def test_mode_fail(
|
async def test_mode_fail(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
mock_config_entry_v25: MockConfigEntry,
|
mock_config_entry_free_current: MockConfigEntry,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test that Minute forecasting fails when mode is not v3.0."""
|
"""Test that Minute forecasting fails when mode is not v3.0."""
|
||||||
await setup_mock_config_entry(hass, mock_config_entry_v25)
|
await setup_mock_config_entry(hass, mock_config_entry_free_current)
|
||||||
|
|
||||||
# Expect a ServiceValidationError when mode is not OWM_MODE_V30
|
# Expect a ServiceValidationError when mode is not OWM_MODE_V30
|
||||||
with pytest.raises(
|
with pytest.raises(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user