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 # If weather alert monitoring is expected initiate a client to be used by
# 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")
from vigilancemeteo import VigilanceMeteoFranceProxy, VigilanceMeteoError from vigilancemeteo import VigilanceMeteoFranceProxy, VigilanceMeteoError
weather_alert_client = VigilanceMeteoFranceProxy() weather_alert_client = VigilanceMeteoFranceProxy()
try: try:
weather_alert_client.update_data() weather_alert_client.update_data()
except VigilanceMeteoError as exp: except VigilanceMeteoError as exp:
_LOGGER.error(exp) _LOGGER.error(
"Unexpected error when creating the" "vigilance_meteoFrance proxy: %s ",
exp,
)
else: else:
weather_alert_client = None weather_alert_client = None
hass.data[DATA_METEO_FRANCE]["weather_alert_client"] = weather_alert_client hass.data[DATA_METEO_FRANCE]["weather_alert_client"] = weather_alert_client
@ -133,7 +137,9 @@ def setup(hass, config):
try: try:
client = meteofranceClient(city) client = meteofranceClient(city)
except meteofranceError as exp: except meteofranceError as exp:
_LOGGER.error(exp) _LOGGER.error(
"Unexpected error when creating the meteofrance proxy: %s", exp
)
return return
client.need_rain_forecast = bool( client.need_rain_forecast = bool(
@ -179,4 +185,6 @@ class MeteoFranceUpdater:
try: try:
self._client.update() self._client.update()
except meteofranceError as exp: 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 datas["dept"], weather_alert_client
) )
except ValueError as exp: 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 alert_watcher = None
else: else:
_LOGGER.info( _LOGGER.info(
"weather alert watcher added for %s" "in department %s", "Weather alert watcher added for %s" "in department %s",
city, city,
datas["dept"], datas["dept"],
) )
else: else:
_LOGGER.warning( _LOGGER.warning(
"No dept key found for '%s'. So weather alert " "No 'dept' key found for '%s'. So weather alert information won't be available",
"information won't be available",
city, city,
) )
# Exit and don't create the sensor if no department code available. # Exit and don't create the sensor if no department code available.