diff --git a/homeassistant/components/downloader.py b/homeassistant/components/downloader.py index b7354b4f0a7d9dadedb9009debf9550651c72d21..0d57740a83d0eea72c4ea17db3254c0c444d6204 100644 --- a/homeassistant/components/downloader.py +++ b/homeassistant/components/downloader.py @@ -25,6 +25,8 @@ ATTR_OVERWRITE = 'overwrite' CONF_DOWNLOAD_DIR = 'download_dir' DOMAIN = 'downloader' +DOWNLOAD_FAILED_EVENT = 'download_failed' +DOWNLOAD_COMPLETED_EVENT = 'download_completed' SERVICE_DOWNLOAD_FILE = 'download_file' @@ -133,9 +135,19 @@ def setup(hass, config): fil.write(chunk) _LOGGER.debug("Downloading of %s done", url) + hass.bus.fire( + "{}_{}".format(DOMAIN, DOWNLOAD_COMPLETED_EVENT), { + 'url': url, + 'filename': filename + }) except requests.exceptions.ConnectionError: _LOGGER.exception("ConnectionError occurred for %s", url) + hass.bus.fire( + "{}_{}".format(DOMAIN, DOWNLOAD_FAILED_EVENT), { + 'url': url, + 'filename': filename + }) # Remove file if we started downloading but failed if final_path and os.path.isfile(final_path):