Meteofrance improve log error messages (#25630)

* Improve log error messages

* remove unique_id not ready yet
This commit is contained in:
Oncleben31 2019-08-01 21:45:16 +02:00 committed by Paulus Schoutsen
parent a177ef02e3
commit f7a47c6cab
2 changed files with 19 additions and 7 deletions

View File

@ -113,13 +113,17 @@ def setup(hass, config):
# If weather alert monitoring is expected initiate a client to be used by
# 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:
weather_alert_client.update_data()
except VigilanceMeteoError as exp:
_LOGGER.error(exp)
_LOGGER.error(
"Unexpected error when creating the" "vigilance_meteoFrance proxy: %s ",
exp,
)
else:
weather_alert_client = None
hass.data[DATA_METEO_FRANCE]["weather_alert_client"] = weather_alert_client
@ -133,7 +137,9 @@ def setup(hass, config):
try:
client = meteofranceClient(city)
except meteofranceError as exp:
_LOGGER.error(exp)
_LOGGER.error(
"Unexpected error when creating the meteofrance proxy: %s", exp
)
return
client.need_rain_forecast = bool(
@ -179,4 +185,6 @@ class MeteoFranceUpdater:
try:
self._client.update()
except meteofranceError as exp:
_LOGGER.error(exp)
_LOGGER.error(
"Unexpected error when updating the meteofrance proxy: %s", exp
)

View File

@ -35,18 +35,22 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
datas["dept"], weather_alert_client
)
except ValueError as exp:
_LOGGER.error(exp)
_LOGGER.error(
"Unexpected error when creating the weather alert sensor for %s in department %s: %s",
city,
datas["dept"],
exp,
)
alert_watcher = None
else:
_LOGGER.info(
"weather alert watcher added for %s" "in department %s",
"Weather alert watcher added for %s" "in department %s",
city,
datas["dept"],
)
else:
_LOGGER.warning(
"No dept key found for '%s'. So weather alert "
"information won't be available",
"No 'dept' key found for '%s'. So weather alert information won't be available",
city,
)
# Exit and don't create the sensor if no department code available.