Move imports to top for meteo_france (#29394)

This commit is contained in:
springstan 2019-12-04 11:16:16 +01:00 committed by Fabian Affolter
parent 849d8c885d
commit 518ca3afa7
4 changed files with 9 additions and 11 deletions

View File

@ -2,6 +2,8 @@
import datetime
import logging
from meteofrance.client import meteofranceClient, meteofranceError
from vigilancemeteo import VigilanceMeteoError, VigilanceMeteoFranceProxy
import voluptuous as vol
from homeassistant.const import CONF_MONITORED_CONDITIONS
@ -9,7 +11,7 @@ import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.discovery import load_platform
from homeassistant.util import Throttle
from .const import DOMAIN, CONF_CITY, SENSOR_TYPES, DATA_METEO_FRANCE
from .const import CONF_CITY, DATA_METEO_FRANCE, DOMAIN, SENSOR_TYPES
_LOGGER = logging.getLogger(__name__)
@ -61,7 +63,6 @@ def setup(hass, config):
# all weather_alert entities.
if need_weather_alert_watcher:
_LOGGER.debug("Weather Alert monitoring expected. Loading vigilancemeteo")
from vigilancemeteo import VigilanceMeteoFranceProxy, VigilanceMeteoError
weather_alert_client = VigilanceMeteoFranceProxy()
try:
@ -79,8 +80,6 @@ def setup(hass, config):
city = location[CONF_CITY]
from meteofrance.client import meteofranceClient, meteofranceError
try:
client = meteofranceClient(city)
except meteofranceError as exp:
@ -127,7 +126,6 @@ class MeteoFranceUpdater:
@Throttle(SCAN_INTERVAL)
def update(self):
"""Get the latest data from Meteo-France."""
from meteofrance.client import meteofranceError
try:
self._client.update()

View File

@ -1,6 +1,8 @@
"""Support for Meteo-France raining forecast sensor."""
import logging
from vigilancemeteo import DepartmentWeatherAlert
from homeassistant.const import ATTR_ATTRIBUTION, CONF_MONITORED_CONDITIONS
from homeassistant.helpers.entity import Entity
@ -8,11 +10,11 @@ from .const import (
ATTRIBUTION,
CONF_CITY,
DATA_METEO_FRANCE,
SENSOR_TYPES,
SENSOR_TYPE_CLASS,
SENSOR_TYPE_ICON,
SENSOR_TYPE_NAME,
SENSOR_TYPE_UNIT,
SENSOR_TYPE_CLASS,
SENSOR_TYPES,
)
_LOGGER = logging.getLogger(__name__)
@ -31,8 +33,6 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
client = hass.data[DATA_METEO_FRANCE][city]
weather_alert_client = hass.data[DATA_METEO_FRANCE]["weather_alert_client"]
from vigilancemeteo import DepartmentWeatherAlert
alert_watcher = None
if "weather_alert" in monitored_conditions:
datas = hass.data[DATA_METEO_FRANCE][city].get_data()

View File

@ -9,8 +9,8 @@ from homeassistant.components.weather import (
ATTR_FORECAST_TIME,
WeatherEntity,
)
import homeassistant.util.dt as dt_util
from homeassistant.const import TEMP_CELSIUS
import homeassistant.util.dt as dt_util
from .const import ATTRIBUTION, CONDITION_CLASSES, CONF_CITY, DATA_METEO_FRANCE

View File

@ -2,6 +2,7 @@
from datetime import timedelta
import logging
from meteoalertapi import Meteoalert
import voluptuous as vol
from homeassistant.components.binary_sensor import PLATFORM_SCHEMA, BinarySensorDevice
@ -33,7 +34,6 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the MeteoAlarm binary sensor platform."""
from meteoalertapi import Meteoalert
country = config[CONF_COUNTRY]
province = config[CONF_PROVINCE]