diff --git a/custom_components/bureau_of_meteorology/__init__.py b/custom_components/bureau_of_meteorology/__init__.py index 1ba04fa9..cb9c5415 100644 --- a/custom_components/bureau_of_meteorology/__init__.py +++ b/custom_components/bureau_of_meteorology/__init__.py @@ -80,10 +80,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: COORDINATOR: coordinator, } - for component in PLATFORMS: - hass.async_create_task( - hass.config_entries.async_forward_entry_setup(entry, component) - ) + await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS) update_listener = entry.add_update_listener(async_update_options) hass.data[DOMAIN][entry.entry_id][UPDATE_LISTENER] = update_listener diff --git a/custom_components/bureau_of_meteorology/manifest.json b/custom_components/bureau_of_meteorology/manifest.json index b9372c37..39e93027 100644 --- a/custom_components/bureau_of_meteorology/manifest.json +++ b/custom_components/bureau_of_meteorology/manifest.json @@ -10,6 +10,6 @@ "zeroconf": [], "homekit": {}, "dependencies": [], - "version": "1.2.0", + "version": "1.3.3", "codeowners": ["@bremor,@makin-things"] } diff --git a/custom_components/bureau_of_meteorology/sensor.py b/custom_components/bureau_of_meteorology/sensor.py index 946ec4cd..d8e7200c 100644 --- a/custom_components/bureau_of_meteorology/sensor.py +++ b/custom_components/bureau_of_meteorology/sensor.py @@ -1,6 +1,6 @@ """Platform for sensor integration.""" import logging -from datetime import datetime, tzinfo +from datetime import datetime, tzinfo, timezone from typing import Any import iso8601 @@ -338,9 +338,9 @@ def state(self): ) else: utc = timezone.utc - local = timezone(self.collector.locations_data["data"]["timezone"]) - start_time = utc.localize(datetime.strptime(self.collector.daily_forecasts_data["data"][self.day]["uv_start_time"], "%Y-%m-%dT%H:%M:%SZ")).astimezone(local) - end_time = utc.localize(datetime.strptime(self.collector.daily_forecasts_data["data"][self.day]["uv_end_time"], "%Y-%m-%dT%H:%M:%SZ")).astimezone(local) + local = zoneinfo.ZoneInfo(self.collector.locations_data["data"]["timezone"]) + start_time = datetime.strptime(self.collector.daily_forecasts_data["data"][self.day]["uv_start_time"], "%Y-%m-%dT%H:%M:%SZ").replace(tzinfo=utc).astimezone(local) + end_time = datetime.strptime(self.collector.daily_forecasts_data["data"][self.day]["uv_end_time"], "%Y-%m-%dT%H:%M:%SZ").replace(tzinfo=utc).astimezone(local) return ( f'Sun protection recommended from {start_time.strftime("%-I:%M%p").lower()} to ' f'{end_time.strftime("%-I:%M%p").lower()}, UV Index predicted to reach '