mirror of
https://github.com/home-assistant/core.git
synced 2025-06-25 01:21:51 +02: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:
@ -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.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 .repairs import async_create_issue, async_delete_issue
|
||||
from .utils import build_data_and_options
|
||||
@ -39,7 +39,7 @@ async def async_setup_entry(
|
||||
language = entry.options[CONF_LANGUAGE]
|
||||
mode = entry.options[CONF_MODE]
|
||||
|
||||
if mode == OWM_MODE_V25:
|
||||
if mode not in OWM_MODES:
|
||||
async_create_issue(hass, entry.entry_id)
|
||||
else:
|
||||
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)
|
||||
|
||||
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)
|
||||
config_entries.async_update_entry(
|
||||
entry,
|
||||
|
@ -62,10 +62,8 @@ FORECAST_MODE_ONECALL_DAILY = "onecall_daily"
|
||||
OWM_MODE_FREE_CURRENT = "current"
|
||||
OWM_MODE_FREE_FORECAST = "forecast"
|
||||
OWM_MODE_V30 = "v3.0"
|
||||
OWM_MODE_V25 = "v2.5"
|
||||
OWM_MODES = [
|
||||
OWM_MODE_V30,
|
||||
OWM_MODE_V25,
|
||||
OWM_MODE_FREE_CURRENT,
|
||||
OWM_MODE_FREE_FORECAST,
|
||||
]
|
||||
|
@ -6,5 +6,5 @@
|
||||
"documentation": "https://www.home-assistant.io/integrations/openweathermap",
|
||||
"iot_class": "cloud_polling",
|
||||
"loggers": ["pyopenweathermap"],
|
||||
"requirements": ["pyopenweathermap==0.2.1"]
|
||||
"requirements": ["pyopenweathermap==0.2.2"]
|
||||
}
|
||||
|
@ -42,7 +42,6 @@ from .const import (
|
||||
DOMAIN,
|
||||
MANUFACTURER,
|
||||
OWM_MODE_FREE_FORECAST,
|
||||
OWM_MODE_V25,
|
||||
OWM_MODE_V30,
|
||||
)
|
||||
from .coordinator import WeatherUpdateCoordinator
|
||||
@ -106,7 +105,7 @@ class OpenWeatherMapWeather(SingleCoordinatorWeatherEntity[WeatherUpdateCoordina
|
||||
)
|
||||
self.mode = mode
|
||||
|
||||
if mode in (OWM_MODE_V30, OWM_MODE_V25):
|
||||
if mode == OWM_MODE_V30:
|
||||
self._attr_supported_features = (
|
||||
WeatherEntityFeature.FORECAST_DAILY
|
||||
| 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
|
||||
|
||||
# homeassistant.components.openweathermap
|
||||
pyopenweathermap==0.2.1
|
||||
pyopenweathermap==0.2.2
|
||||
|
||||
# homeassistant.components.opnsense
|
||||
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
|
||||
|
||||
# homeassistant.components.openweathermap
|
||||
pyopenweathermap==0.2.1
|
||||
pyopenweathermap==0.2.2
|
||||
|
||||
# homeassistant.components.opnsense
|
||||
pyopnsense==0.4.0
|
||||
|
@ -6,7 +6,7 @@ from syrupy import SnapshotAssertion
|
||||
from homeassistant.components.openweathermap.const import (
|
||||
DEFAULT_LANGUAGE,
|
||||
DOMAIN,
|
||||
OWM_MODE_V25,
|
||||
OWM_MODE_FREE_CURRENT,
|
||||
OWM_MODE_V30,
|
||||
)
|
||||
from homeassistant.components.openweathermap.weather import SERVICE_GET_MINUTE_FORECAST
|
||||
@ -52,9 +52,9 @@ def mock_config_entry(mode: str) -> MockConfigEntry:
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def mock_config_entry_v25() -> MockConfigEntry:
|
||||
"""Create a mock OpenWeatherMap v2.5 config entry."""
|
||||
return mock_config_entry(OWM_MODE_V25)
|
||||
def mock_config_entry_free_current() -> MockConfigEntry:
|
||||
"""Create a mock OpenWeatherMap FREE_CURRENT config entry."""
|
||||
return mock_config_entry(OWM_MODE_FREE_CURRENT)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
@ -97,15 +97,15 @@ async def test_get_minute_forecast(
|
||||
|
||||
|
||||
@patch(
|
||||
"pyopenweathermap.client.onecall_client.OWMOneCallClient.get_weather",
|
||||
"pyopenweathermap.client.free_client.OWMFreeClient.get_weather",
|
||||
AsyncMock(return_value=static_weather_report),
|
||||
)
|
||||
async def test_mode_fail(
|
||||
hass: HomeAssistant,
|
||||
mock_config_entry_v25: MockConfigEntry,
|
||||
mock_config_entry_free_current: MockConfigEntry,
|
||||
) -> None:
|
||||
"""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
|
||||
with pytest.raises(
|
||||
|
Reference in New Issue
Block a user