From 4489cf82e6a17316ee233b55dd14b675f27d2a40 Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Thu, 14 Feb 2019 14:45:21 +0100 Subject: [PATCH 1/5] Move files --- .../components/{meteo_france.py => meteo_france/__init__.py} | 0 .../{weather/meteo_france.py => meteo_france/weather.py} | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename homeassistant/components/{meteo_france.py => meteo_france/__init__.py} (100%) rename homeassistant/components/{weather/meteo_france.py => meteo_france/weather.py} (100%) diff --git a/homeassistant/components/meteo_france.py b/homeassistant/components/meteo_france/__init__.py similarity index 100% rename from homeassistant/components/meteo_france.py rename to homeassistant/components/meteo_france/__init__.py diff --git a/homeassistant/components/weather/meteo_france.py b/homeassistant/components/meteo_france/weather.py similarity index 100% rename from homeassistant/components/weather/meteo_france.py rename to homeassistant/components/meteo_france/weather.py From 54dbf8497b0735b5abfadc70b76fe040515e309d Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Thu, 14 Feb 2019 14:48:08 +0100 Subject: [PATCH 2/5] Move file --- .../components/{sensor/meteo_france.py => meteo_france/sensor.py} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename homeassistant/components/{sensor/meteo_france.py => meteo_france/sensor.py} (100%) diff --git a/homeassistant/components/sensor/meteo_france.py b/homeassistant/components/meteo_france/sensor.py similarity index 100% rename from homeassistant/components/sensor/meteo_france.py rename to homeassistant/components/meteo_france/sensor.py From e09b84f01b0c82e3942b721df9c7920a4b6bde13 Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Thu, 14 Feb 2019 14:48:41 +0100 Subject: [PATCH 3/5] Update .coveragerc --- .coveragerc | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.coveragerc b/.coveragerc index 1302ee911a3e28..4e06eaaef29c5f 100644 --- a/.coveragerc +++ b/.coveragerc @@ -317,6 +317,7 @@ omit = homeassistant/components/media_player/yamaha_musiccast.py homeassistant/components/media_player/yamaha.py homeassistant/components/media_player/ziggo_mediabox_xl.py + homeassistant/components/meteo_france/* homeassistant/components/mochad/* homeassistant/components/modbus/* homeassistant/components/mychevy/* @@ -326,7 +327,6 @@ omit = homeassistant/components/nest/* homeassistant/components/netatmo/* homeassistant/components/netgear_lte/* - homeassistant/components/meteo_france.py homeassistant/components/notify/aws_lambda.py homeassistant/components/notify/aws_sns.py homeassistant/components/notify/aws_sqs.py @@ -483,7 +483,6 @@ omit = homeassistant/components/sensor/loopenergy.py homeassistant/components/sensor/lyft.py homeassistant/components/sensor/magicseaweed.py - homeassistant/components/sensor/meteo_france.py homeassistant/components/sensor/metoffice.py homeassistant/components/sensor/miflora.py homeassistant/components/sensor/mitemp_bt.py @@ -651,7 +650,6 @@ omit = homeassistant/components/weather/buienradar.py homeassistant/components/weather/darksky.py homeassistant/components/weather/met.py - homeassistant/components/weather/meteo_france.py homeassistant/components/weather/metoffice.py homeassistant/components/weather/openweathermap.py homeassistant/components/weather/zamg.py From ece457d1f173b4981750951349090d2722a14e37 Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Thu, 14 Feb 2019 14:50:01 +0100 Subject: [PATCH 4/5] Sort import and update file header --- .../components/meteo_france/__init__.py | 16 +++++----------- homeassistant/components/meteo_france/sensor.py | 17 ++++------------- 2 files changed, 9 insertions(+), 24 deletions(-) diff --git a/homeassistant/components/meteo_france/__init__.py b/homeassistant/components/meteo_france/__init__.py index fa68021d91c7ac..8fc6438c870952 100644 --- a/homeassistant/components/meteo_france/__init__.py +++ b/homeassistant/components/meteo_france/__init__.py @@ -1,19 +1,13 @@ -""" -Support for Meteo France weather forecast. - -For more details about this platform, please refer to the documentation at -https://home-assistant.io/components/meteo_france/ -""" -import logging +"""Support for Meteo France weather forecast.""" import datetime +import logging import voluptuous as vol -from homeassistant.const import ( - CONF_MONITORED_CONDITIONS, TEMP_CELSIUS) -from homeassistant.util import Throttle -from homeassistant.helpers.discovery import load_platform +from homeassistant.const import CONF_MONITORED_CONDITIONS, TEMP_CELSIUS import homeassistant.helpers.config_validation as cv +from homeassistant.helpers.discovery import load_platform +from homeassistant.util import Throttle REQUIREMENTS = ['meteofrance==0.3.4'] _LOGGER = logging.getLogger(__name__) diff --git a/homeassistant/components/meteo_france/sensor.py b/homeassistant/components/meteo_france/sensor.py index 12933c02e81106..d1bbcf0ea2e912 100644 --- a/homeassistant/components/meteo_france/sensor.py +++ b/homeassistant/components/meteo_france/sensor.py @@ -1,18 +1,9 @@ -""" -Support for Meteo France raining forecast. - -For more details about this platform, please refer to the documentation at -https://home-assistant.io/components/sensor.meteo_france/ -""" +"""Support for Meteo France raining forecast sensor.""" import logging - -from homeassistant.components.meteo_france import (SENSOR_TYPES, - DATA_METEO_FRANCE, - CONF_CITY, - ATTRIBUTION) -from homeassistant.const import ( - CONF_MONITORED_CONDITIONS, ATTR_ATTRIBUTION) +from homeassistant.components.meteo_france import ( + ATTRIBUTION, CONF_CITY, DATA_METEO_FRANCE, SENSOR_TYPES) +from homeassistant.const import ATTR_ATTRIBUTION, CONF_MONITORED_CONDITIONS from homeassistant.helpers.entity import Entity _LOGGER = logging.getLogger(__name__) From c9292e9a85a63f0f2c52016eddc2f274603dd3b3 Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Thu, 14 Feb 2019 15:46:04 +0100 Subject: [PATCH 5/5] Minor changes --- .../components/meteo_france/__init__.py | 36 +++++++++---------- .../components/meteo_france/sensor.py | 30 +++++++--------- .../components/meteo_france/weather.py | 23 ++++++------ 3 files changed, 39 insertions(+), 50 deletions(-) diff --git a/homeassistant/components/meteo_france/__init__.py b/homeassistant/components/meteo_france/__init__.py index 8fc6438c870952..e084cff3c79c73 100644 --- a/homeassistant/components/meteo_france/__init__.py +++ b/homeassistant/components/meteo_france/__init__.py @@ -1,4 +1,4 @@ -"""Support for Meteo France weather forecast.""" +"""Support for Meteo-France weather data.""" import datetime import logging @@ -10,14 +10,18 @@ from homeassistant.util import Throttle REQUIREMENTS = ['meteofrance==0.3.4'] + _LOGGER = logging.getLogger(__name__) -DOMAIN = 'meteo_france' -SCAN_INTERVAL = datetime.timedelta(minutes=5) ATTRIBUTION = "Data provided by Météo-France" + CONF_CITY = 'city' -DEFAULT_WEATHER_CARD = True + DATA_METEO_FRANCE = 'data_meteo_france' +DEFAULT_WEATHER_CARD = True +DOMAIN = 'meteo_france' + +SCAN_INTERVAL = datetime.timedelta(minutes=5) SENSOR_TYPES = { 'rain_chance': ['Rain chance', '%'], @@ -87,9 +91,9 @@ def setup(hass, config): _LOGGER.error(exp) return - client.need_rain_forecast = bool(CONF_MONITORED_CONDITIONS in location - and 'next_rain' in - location[CONF_MONITORED_CONDITIONS]) + client.need_rain_forecast = bool( + CONF_MONITORED_CONDITIONS in location and 'next_rain' in + location[CONF_MONITORED_CONDITIONS]) hass.data[DATA_METEO_FRANCE][city] = MeteoFranceUpdater(client) hass.data[DATA_METEO_FRANCE][city].update() @@ -97,19 +101,11 @@ def setup(hass, config): if CONF_MONITORED_CONDITIONS in location: monitored_conditions = location[CONF_MONITORED_CONDITIONS] load_platform( - hass, - 'sensor', - DOMAIN, - {CONF_CITY: city, - CONF_MONITORED_CONDITIONS: monitored_conditions}, - config) - - load_platform( - hass, - 'weather', - DOMAIN, - {CONF_CITY: city}, - config) + hass, 'sensor', DOMAIN, { + CONF_CITY: city, + CONF_MONITORED_CONDITIONS: monitored_conditions}, config) + + load_platform(hass, 'weather', DOMAIN, {CONF_CITY: city}, config) return True diff --git a/homeassistant/components/meteo_france/sensor.py b/homeassistant/components/meteo_france/sensor.py index d1bbcf0ea2e912..f0ef926793e0a9 100644 --- a/homeassistant/components/meteo_france/sensor.py +++ b/homeassistant/components/meteo_france/sensor.py @@ -1,4 +1,4 @@ -"""Support for Meteo France raining forecast sensor.""" +"""Support for Meteo-France raining forecast sensor.""" import logging from homeassistant.components.meteo_france import ( @@ -18,19 +18,17 @@ def setup_platform(hass, config, add_entities, discovery_info=None): city = discovery_info[CONF_CITY] monitored_conditions = discovery_info[CONF_MONITORED_CONDITIONS] - client = hass.data[DATA_METEO_FRANCE][city] add_entities([MeteoFranceSensor(variable, client) - for variable in monitored_conditions], - True) + for variable in monitored_conditions], True) class MeteoFranceSensor(Entity): - """Representation of a Sensor.""" + """Representation of a Meteo-France sensor.""" def __init__(self, condition, client): - """Initialize the sensor.""" + """Initialize the Meteo-France sensor.""" self._condition = condition self._client = client self._state = None @@ -39,8 +37,8 @@ def __init__(self, condition, client): @property def name(self): """Return the name of the sensor.""" - return "{} {}".format(self._data["name"], - SENSOR_TYPES[self._condition][0]) + return "{} {}".format( + self._data['name'], SENSOR_TYPES[self._condition][0]) @property def state(self): @@ -50,15 +48,11 @@ def state(self): @property def device_state_attributes(self): """Return the state attributes of the sensor.""" - if self._condition == 'next_rain' and "rain_forecast" in self._data: + if self._condition == 'next_rain' and 'rain_forecast' in self._data: return { - **{ - STATE_ATTR_FORECAST: self._data["rain_forecast"], - }, - ** self._data["next_rain_intervals"], - **{ - ATTR_ATTRIBUTION: ATTRIBUTION - } + **{STATE_ATTR_FORECAST: self._data['rain_forecast']}, + ** self._data['next_rain_intervals'], + **{ATTR_ATTRIBUTION: ATTRIBUTION} } return {ATTR_ATTRIBUTION: ATTRIBUTION} @@ -74,6 +68,6 @@ def update(self): self._data = self._client.get_data() self._state = self._data[self._condition] except KeyError: - _LOGGER.error("No condition `%s` for location `%s`", - self._condition, self._data["name"]) + _LOGGER.error("No condition %s for location %s", + self._condition, self._data['name']) self._state = None diff --git a/homeassistant/components/meteo_france/weather.py b/homeassistant/components/meteo_france/weather.py index cf8b2b497fb32e..849c9d9da10de5 100644 --- a/homeassistant/components/meteo_france/weather.py +++ b/homeassistant/components/meteo_france/weather.py @@ -1,4 +1,4 @@ -"""Support for Meteo france weather service.""" +"""Support for Meteo-France weather service.""" from datetime import datetime, timedelta import logging @@ -18,7 +18,6 @@ def setup_platform(hass, config, add_entities, discovery_info=None): return city = discovery_info[CONF_CITY] - client = hass.data[DATA_METEO_FRANCE][city] add_entities([MeteoFranceWeather(client)], True) @@ -40,21 +39,21 @@ def update(self): @property def name(self): """Return the name of the sensor.""" - return self._data["name"] + return self._data['name'] @property def condition(self): """Return the current condition.""" - return self.format_condition(self._data["weather"]) + return self.format_condition(self._data['weather']) @property def temperature(self): - """Return the platform temperature.""" - return self._data["temperature"] + """Return the temperature.""" + return self._data['temperature'] @property def humidity(self): - """Return the platform temperature.""" + """Return the humidity.""" return None @property @@ -65,12 +64,12 @@ def temperature_unit(self): @property def wind_speed(self): """Return the wind speed.""" - return self._data["wind_speed"] + return self._data['wind_speed'] @property def wind_bearing(self): """Return the wind bearing.""" - return self._data["wind_bearing"] + return self._data['wind_bearing'] @property def attribution(self): @@ -83,14 +82,14 @@ def forecast(self): reftime = datetime.now().replace(hour=12, minute=00) reftime += timedelta(hours=24) forecast_data = [] - for key in self._data["forecast"]: - value = self._data["forecast"][key] + for key in self._data['forecast']: + value = self._data['forecast'][key] data_dict = { ATTR_FORECAST_TIME: reftime.isoformat(), ATTR_FORECAST_TEMP: int(value['max_temp']), ATTR_FORECAST_TEMP_LOW: int(value['min_temp']), ATTR_FORECAST_CONDITION: - self.format_condition(value["weather"]) + self.format_condition(value['weather']) } reftime = reftime + timedelta(hours=24) forecast_data.append(data_dict)