mirror of
https://github.com/home-assistant/core.git
synced 2025-07-24 21:57:51 +00:00
Move imports to top for meteo_france (#29394)
This commit is contained in:
parent
849d8c885d
commit
518ca3afa7
@ -2,6 +2,8 @@
|
|||||||
import datetime
|
import datetime
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
from meteofrance.client import meteofranceClient, meteofranceError
|
||||||
|
from vigilancemeteo import VigilanceMeteoError, VigilanceMeteoFranceProxy
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.const import CONF_MONITORED_CONDITIONS
|
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.helpers.discovery import load_platform
|
||||||
from homeassistant.util import Throttle
|
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__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -61,7 +63,6 @@ def setup(hass, config):
|
|||||||
# all weather_alert entities.
|
# all weather_alert entities.
|
||||||
if need_weather_alert_watcher:
|
if need_weather_alert_watcher:
|
||||||
_LOGGER.debug("Weather Alert monitoring expected. Loading vigilancemeteo")
|
_LOGGER.debug("Weather Alert monitoring expected. Loading vigilancemeteo")
|
||||||
from vigilancemeteo import VigilanceMeteoFranceProxy, VigilanceMeteoError
|
|
||||||
|
|
||||||
weather_alert_client = VigilanceMeteoFranceProxy()
|
weather_alert_client = VigilanceMeteoFranceProxy()
|
||||||
try:
|
try:
|
||||||
@ -79,8 +80,6 @@ def setup(hass, config):
|
|||||||
|
|
||||||
city = location[CONF_CITY]
|
city = location[CONF_CITY]
|
||||||
|
|
||||||
from meteofrance.client import meteofranceClient, meteofranceError
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
client = meteofranceClient(city)
|
client = meteofranceClient(city)
|
||||||
except meteofranceError as exp:
|
except meteofranceError as exp:
|
||||||
@ -127,7 +126,6 @@ class MeteoFranceUpdater:
|
|||||||
@Throttle(SCAN_INTERVAL)
|
@Throttle(SCAN_INTERVAL)
|
||||||
def update(self):
|
def update(self):
|
||||||
"""Get the latest data from Meteo-France."""
|
"""Get the latest data from Meteo-France."""
|
||||||
from meteofrance.client import meteofranceError
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self._client.update()
|
self._client.update()
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
"""Support for Meteo-France raining forecast sensor."""
|
"""Support for Meteo-France raining forecast sensor."""
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
from vigilancemeteo import DepartmentWeatherAlert
|
||||||
|
|
||||||
from homeassistant.const import ATTR_ATTRIBUTION, CONF_MONITORED_CONDITIONS
|
from homeassistant.const import ATTR_ATTRIBUTION, CONF_MONITORED_CONDITIONS
|
||||||
from homeassistant.helpers.entity import Entity
|
from homeassistant.helpers.entity import Entity
|
||||||
|
|
||||||
@ -8,11 +10,11 @@ from .const import (
|
|||||||
ATTRIBUTION,
|
ATTRIBUTION,
|
||||||
CONF_CITY,
|
CONF_CITY,
|
||||||
DATA_METEO_FRANCE,
|
DATA_METEO_FRANCE,
|
||||||
SENSOR_TYPES,
|
SENSOR_TYPE_CLASS,
|
||||||
SENSOR_TYPE_ICON,
|
SENSOR_TYPE_ICON,
|
||||||
SENSOR_TYPE_NAME,
|
SENSOR_TYPE_NAME,
|
||||||
SENSOR_TYPE_UNIT,
|
SENSOR_TYPE_UNIT,
|
||||||
SENSOR_TYPE_CLASS,
|
SENSOR_TYPES,
|
||||||
)
|
)
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_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]
|
client = hass.data[DATA_METEO_FRANCE][city]
|
||||||
weather_alert_client = hass.data[DATA_METEO_FRANCE]["weather_alert_client"]
|
weather_alert_client = hass.data[DATA_METEO_FRANCE]["weather_alert_client"]
|
||||||
|
|
||||||
from vigilancemeteo import DepartmentWeatherAlert
|
|
||||||
|
|
||||||
alert_watcher = None
|
alert_watcher = None
|
||||||
if "weather_alert" in monitored_conditions:
|
if "weather_alert" in monitored_conditions:
|
||||||
datas = hass.data[DATA_METEO_FRANCE][city].get_data()
|
datas = hass.data[DATA_METEO_FRANCE][city].get_data()
|
||||||
|
@ -9,8 +9,8 @@ from homeassistant.components.weather import (
|
|||||||
ATTR_FORECAST_TIME,
|
ATTR_FORECAST_TIME,
|
||||||
WeatherEntity,
|
WeatherEntity,
|
||||||
)
|
)
|
||||||
import homeassistant.util.dt as dt_util
|
|
||||||
from homeassistant.const import TEMP_CELSIUS
|
from homeassistant.const import TEMP_CELSIUS
|
||||||
|
import homeassistant.util.dt as dt_util
|
||||||
|
|
||||||
from .const import ATTRIBUTION, CONDITION_CLASSES, CONF_CITY, DATA_METEO_FRANCE
|
from .const import ATTRIBUTION, CONDITION_CLASSES, CONF_CITY, DATA_METEO_FRANCE
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
from meteoalertapi import Meteoalert
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.components.binary_sensor import PLATFORM_SCHEMA, BinarySensorDevice
|
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):
|
def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||||
"""Set up the MeteoAlarm binary sensor platform."""
|
"""Set up the MeteoAlarm binary sensor platform."""
|
||||||
from meteoalertapi import Meteoalert
|
|
||||||
|
|
||||||
country = config[CONF_COUNTRY]
|
country = config[CONF_COUNTRY]
|
||||||
province = config[CONF_PROVINCE]
|
province = config[CONF_PROVINCE]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user