From a160743cbe359ba65c33f7dc2d3e9b503fa3f763 Mon Sep 17 00:00:00 2001 From: dave_albright Date: Fri, 8 Nov 2024 08:24:55 -0700 Subject: [PATCH] v2.0.9 replace removed python async_timeout.timeout with asyncio.timeout addresses issues in discussion #s 260 and 261 --- changelog.md | 6 +++++- custom_components/wundergroundpws/config_flow.py | 4 ++-- custom_components/wundergroundpws/coordinator.py | 6 +++--- custom_components/wundergroundpws/manifest.json | 2 +- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/changelog.md b/changelog.md index 1c74ac3..5091a45 100644 --- a/changelog.md +++ b/changelog.md @@ -1,4 +1,8 @@ -v2.08 +v2.0.9 +replace removed python async_timeout.timeout with asyncio.timeout +addresses issues in discussion #s [260](https://github.com/cytech/Home-Assistant-wundergroundpws/discussions/260) and [261](https://github.com/cytech/Home-Assistant-wundergroundpws/discussions/261) + +v2.0.8 modify Forecast Summary sensor initialization. when integration was loaded after 3:00 pm apparent time, None was set as value type instead of string, causing failure. addresses issues in discussion #s [248](https://github.com/cytech/Home-Assistant-wundergroundpws/discussions/248) and [246](https://github.com/cytech/Home-Assistant-wundergroundpws/discussions/246) diff --git a/custom_components/wundergroundpws/config_flow.py b/custom_components/wundergroundpws/config_flow.py index 7754596..f47a04d 100644 --- a/custom_components/wundergroundpws/config_flow.py +++ b/custom_components/wundergroundpws/config_flow.py @@ -2,7 +2,7 @@ from __future__ import annotations import logging from http import HTTPStatus -import async_timeout +from asyncio import timeout import voluptuous as vol from homeassistant import config_entries import homeassistant.helpers.config_validation as cv @@ -55,7 +55,7 @@ async def async_step_user(self, user_input=None): errors["base"] = "invalid_station_id" raise InvalidStationId - with async_timeout.timeout(DEFAULT_TIMEOUT): + async with timeout(DEFAULT_TIMEOUT): url = f'https://api.weather.com/v2/pws/observations/current?stationId={pws_id}&format=json&units=e' \ f'&apiKey={api_key}' response = await session.get(url, headers=headers) diff --git a/custom_components/wundergroundpws/coordinator.py b/custom_components/wundergroundpws/coordinator.py index 0d99e13..9d2b124 100755 --- a/custom_components/wundergroundpws/coordinator.py +++ b/custom_components/wundergroundpws/coordinator.py @@ -9,7 +9,7 @@ from typing import Any import aiohttp -import async_timeout +from asyncio import timeout from homeassistant.core import HomeAssistant from homeassistant.exceptions import HomeAssistantError @@ -122,7 +122,7 @@ async def get_weather(self): "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36" } try: - with async_timeout.timeout(DEFAULT_TIMEOUT): + async with timeout(DEFAULT_TIMEOUT): url = self._build_url(_RESOURCECURRENT) response = await self._session.get(url, headers=headers) result_current = await response.json() @@ -135,7 +135,7 @@ async def get_weather(self): if not self._latitude: self._latitude = (result_current[FIELD_OBSERVATIONS][0][FIELD_LATITUDE]) - with async_timeout.timeout(DEFAULT_TIMEOUT): + async with timeout(DEFAULT_TIMEOUT): url = self._build_url(_RESOURCEFORECAST) response = await self._session.get(url, headers=headers) result_forecast = await response.json() diff --git a/custom_components/wundergroundpws/manifest.json b/custom_components/wundergroundpws/manifest.json index e232a05..a8c6015 100644 --- a/custom_components/wundergroundpws/manifest.json +++ b/custom_components/wundergroundpws/manifest.json @@ -1,7 +1,7 @@ { "domain": "wundergroundpws", "name": "Wundergroundpws", - "version": "2.0.8", + "version": "2.0.9", "documentation": "https://github.com/cytech/Home-Assistant-wundergroundpws/", "issue_tracker": "https://github.com/cytech/Home-Assistant-wundergroundpws/discussions/", "requirements": [],