From fed36d2cd035b527d0ebb398e017bbd2d09e15c3 Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Sun, 26 Jul 2015 00:14:55 -0700 Subject: [PATCH] Better error reporting remote classes --- homeassistant/components/http.py | 12 ++++++++---- homeassistant/remote.py | 5 +++-- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/homeassistant/components/http.py b/homeassistant/components/http.py index c1c0899c9ef..cb8e87490f3 100644 --- a/homeassistant/components/http.py +++ b/homeassistant/components/http.py @@ -119,7 +119,6 @@ _LOGGER = logging.getLogger(__name__) def setup(hass, config=None): """ Sets up the HTTP API and debug interface. """ - if config is None or DOMAIN not in config: config = {DOMAIN: {}} @@ -139,9 +138,14 @@ def setup(hass, config=None): sessions_enabled = config[DOMAIN].get(CONF_SESSIONS_ENABLED, True) - server = HomeAssistantHTTPServer( - (server_host, server_port), RequestHandler, hass, api_password, - development, no_password_set, sessions_enabled) + try: + server = HomeAssistantHTTPServer( + (server_host, server_port), RequestHandler, hass, api_password, + development, no_password_set, sessions_enabled) + except OSError: + # Happens if address already in use + _LOGGER.exception("Error setting up HTTP server") + return False hass.bus.listen_once( ha.EVENT_HOMEASSISTANT_START, diff --git a/homeassistant/remote.py b/homeassistant/remote.py index bd576f50e48..3decfa3ce3e 100644 --- a/homeassistant/remote.py +++ b/homeassistant/remote.py @@ -120,8 +120,9 @@ class HomeAssistant(ha.HomeAssistant): def start(self): # Ensure a local API exists to connect with remote if self.config.api is None: - bootstrap.setup_component(self, 'http') - bootstrap.setup_component(self, 'api') + if not bootstrap.setup_component(self, 'api'): + raise ha.HomeAssistantError( + 'Unable to setup local API to receive events') ha.Timer(self)