From 3e795f676fc7ef6bddcfae7925d494611f0d8882 Mon Sep 17 00:00:00 2001 From: FL550 Date: Tue, 6 Feb 2024 12:17:04 +0100 Subject: [PATCH] Formatting --- custom_components/dwd_weather/connector.py | 39 +++++++++++++--------- custom_components/dwd_weather/const.py | 1 + custom_components/dwd_weather/entity.py | 5 ++- custom_components/dwd_weather/weather.py | 1 + 4 files changed, 29 insertions(+), 17 deletions(-) diff --git a/custom_components/dwd_weather/connector.py b/custom_components/dwd_weather/connector.py index 5a38962..e108e68 100644 --- a/custom_components/dwd_weather/connector.py +++ b/custom_components/dwd_weather/connector.py @@ -1,4 +1,5 @@ """Connector class to retrieve data, which is use by the weather and sensor enities.""" + import logging from datetime import datetime, timedelta, timezone import time @@ -92,10 +93,12 @@ def _update(self): self.dwd_weather.update( force_hourly=self._config[CONF_HOURLY_UPDATE], with_forecast=True, - with_measurements=True - if self._config[CONF_DATA_TYPE] == CONF_DATA_TYPE_REPORT - or self._config[CONF_DATA_TYPE] == CONF_DATA_TYPE_MIXED - else False, + with_measurements=( + True + if self._config[CONF_DATA_TYPE] == CONF_DATA_TYPE_REPORT + or self._config[CONF_DATA_TYPE] == CONF_DATA_TYPE_MIXED + else False + ), with_report=True, ) if self._config[CONF_HOURLY_UPDATE]: @@ -240,12 +243,12 @@ def get_forecast(self, WeatherEntityFeature_FORECAST) -> list[Forecast] | None: False, ), ATTR_FORECAST_WIND_BEARING: wind_dir, - ATTR_FORECAST_NATIVE_WIND_SPEED: round(wind_speed * 3.6, 1) - if wind_speed is not None - else None, - ATTR_WEATHER_WIND_GUST_SPEED: round(wind_gusts * 3.6, 1) - if wind_gusts is not None - else None, + ATTR_FORECAST_NATIVE_WIND_SPEED: ( + round(wind_speed * 3.6, 1) if wind_speed is not None else None + ), + ATTR_WEATHER_WIND_GUST_SPEED: ( + round(wind_gusts * 3.6, 1) if wind_gusts is not None else None + ), "uv_index": uv_index, "precipitation_probability": precipitation_prop, } @@ -314,9 +317,11 @@ def get_weather_value(self, data_type: WeatherDataType): WeatherDataType.DEWPOINT: lambda x: round(x - 273.1, 1), WeatherDataType.PRESSURE: lambda x: round(x / 100, 1), WeatherDataType.WIND_SPEED: lambda x: round(x * 3.6, 1), - WeatherDataType.WIND_DIRECTION: lambda x: round(x, 0) - if self._config[CONF_WIND_DIRECTION_TYPE] == DEFAULT_WIND_DIRECTION_TYPE - else self.get_wind_direction_symbol(round(x, 0)), + WeatherDataType.WIND_DIRECTION: lambda x: ( + round(x, 0) + if self._config[CONF_WIND_DIRECTION_TYPE] == DEFAULT_WIND_DIRECTION_TYPE + else self.get_wind_direction_symbol(round(x, 0)) + ), WeatherDataType.WIND_GUSTS: lambda x: round(x * 3.6, 1), WeatherDataType.PRECIPITATION: lambda x: round(x, 1), WeatherDataType.PRECIPITATION_PROBABILITY: lambda x: round(x, 0), @@ -412,9 +417,11 @@ def get_hourly(self, data_type: WeatherDataType): WeatherDataType.DEWPOINT: lambda value: round(value - 273.1, 1), WeatherDataType.PRESSURE: lambda value: round(value / 100, 1), WeatherDataType.WIND_SPEED: lambda value: round(value * 3.6, 1), - WeatherDataType.WIND_DIRECTION: lambda value: round(value, 0) - if self._config[CONF_WIND_DIRECTION_TYPE] == DEFAULT_WIND_DIRECTION_TYPE - else self.get_wind_direction_symbol(round(value, 0)), + WeatherDataType.WIND_DIRECTION: lambda value: ( + round(value, 0) + if self._config[CONF_WIND_DIRECTION_TYPE] == DEFAULT_WIND_DIRECTION_TYPE + else self.get_wind_direction_symbol(round(value, 0)) + ), WeatherDataType.WIND_GUSTS: lambda value: round(value * 3.6, 1), WeatherDataType.PRECIPITATION: lambda value: round(value, 1), WeatherDataType.PRECIPITATION_PROBABILITY: lambda value: round(value, 0), diff --git a/custom_components/dwd_weather/const.py b/custom_components/dwd_weather/const.py index 27b02ca..03cb47c 100644 --- a/custom_components/dwd_weather/const.py +++ b/custom_components/dwd_weather/const.py @@ -1,4 +1,5 @@ """Constants for the DWD Weather integration.""" + from datetime import timedelta from homeassistant.const import Platform diff --git a/custom_components/dwd_weather/entity.py b/custom_components/dwd_weather/entity.py index 6a8d441..a80afd1 100644 --- a/custom_components/dwd_weather/entity.py +++ b/custom_components/dwd_weather/entity.py @@ -1,4 +1,5 @@ """DWDWeatherEntity class.""" + import logging from homeassistant.helpers.device_registry import DeviceEntryType from homeassistant.helpers.entity import DeviceInfo @@ -23,7 +24,9 @@ def __init__(self, hass_data, unique_id): self._connector = hass_data[DWDWEATHER_DATA] self._coordinator = hass_data[DWDWEATHER_COORDINATOR] self._station_name = self._connector._config[CONF_STATION_NAME] - self._device_id = f"{self._connector.dwd_weather.station_id}: {self._station_name}" + self._device_id = ( + f"{self._connector.dwd_weather.station_id}: {self._station_name}" + ) self._unique_id = unique_id @property diff --git a/custom_components/dwd_weather/weather.py b/custom_components/dwd_weather/weather.py index 73a764d..a62c868 100644 --- a/custom_components/dwd_weather/weather.py +++ b/custom_components/dwd_weather/weather.py @@ -1,4 +1,5 @@ """Support for DWD weather service.""" + import logging from custom_components.dwd_weather.connector import DWDWeatherData from custom_components.dwd_weather.entity import DWDWeatherEntity