From 7ee37648d878b05816a1f0c797327236bf49497f Mon Sep 17 00:00:00 2001 From: jamespcole Date: Mon, 9 Mar 2015 08:45:20 +1100 Subject: [PATCH] Updated exception type for errors when connecting to vera --- homeassistant/components/light/vera.py | 4 ++-- homeassistant/components/sensor/vera.py | 3 ++- homeassistant/components/switch/vera.py | 3 ++- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/homeassistant/components/light/vera.py b/homeassistant/components/light/vera.py index 50dc86dfdb5..e3173c8c88d 100644 --- a/homeassistant/components/light/vera.py +++ b/homeassistant/components/light/vera.py @@ -52,6 +52,7 @@ it should be set to "true" if you want this device excluded """ import logging +from requests.exceptions import RequestException from homeassistant.components.switch.vera import VeraSwitch # pylint: disable=no-name-in-module, import-error import homeassistant.external.vera.vera as veraApi @@ -77,7 +78,7 @@ def setup_platform(hass, config, add_devices_callback, discovery_info=None): devices = [] try: devices = controller.get_devices('Switch') - except IOError as inst: + except RequestException as inst: # There was a network related error connecting to the vera controller _LOGGER.error("Could not find Vera lights: %s", inst) return False @@ -93,4 +94,3 @@ def setup_platform(hass, config, add_devices_callback, discovery_info=None): lights.append(VeraSwitch(device, extra_data)) add_devices_callback(lights) - diff --git a/homeassistant/components/sensor/vera.py b/homeassistant/components/sensor/vera.py index 78e5528c792..0f4170fa806 100644 --- a/homeassistant/components/sensor/vera.py +++ b/homeassistant/components/sensor/vera.py @@ -48,6 +48,7 @@ it should be set to "true" if you want this device excluded """ import logging import time +from requests.exceptions import RequestException from homeassistant.helpers import Device from homeassistant.const import ( @@ -77,7 +78,7 @@ def get_devices(hass, config): devices = [] try: devices = vera_controller.get_devices(categories) - except IOError as inst: + except RequestException as inst: # There was a network related error connecting to the vera controller _LOGGER.error("Could not find Vera sensors: %s", inst) return False diff --git a/homeassistant/components/switch/vera.py b/homeassistant/components/switch/vera.py index e6906e9c075..828212d70d2 100644 --- a/homeassistant/components/switch/vera.py +++ b/homeassistant/components/switch/vera.py @@ -50,6 +50,7 @@ it should be set to "true" if you want this device excluded """ import logging import time +from requests.exceptions import RequestException from homeassistant.helpers import ToggleDevice from homeassistant.const import ( @@ -78,7 +79,7 @@ def get_devices(hass, config): devices = [] try: devices = vera_controller.get_devices(['Switch', 'Armable Sensor']) - except IOError as inst: + except RequestException as inst: # There was a network related error connecting to the vera controller _LOGGER.error("Could not find Vera switches: %s", inst) return False