mirror of
https://github.com/home-assistant/core.git
synced 2025-07-24 21:57:51 +00:00
Updated exception type for errors when connecting to vera
This commit is contained in:
parent
95852db18d
commit
7ee37648d8
@ -52,6 +52,7 @@ it should be set to "true" if you want this device excluded
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
import logging
|
import logging
|
||||||
|
from requests.exceptions import RequestException
|
||||||
from homeassistant.components.switch.vera import VeraSwitch
|
from homeassistant.components.switch.vera import VeraSwitch
|
||||||
# pylint: disable=no-name-in-module, import-error
|
# pylint: disable=no-name-in-module, import-error
|
||||||
import homeassistant.external.vera.vera as veraApi
|
import homeassistant.external.vera.vera as veraApi
|
||||||
@ -77,7 +78,7 @@ def setup_platform(hass, config, add_devices_callback, discovery_info=None):
|
|||||||
devices = []
|
devices = []
|
||||||
try:
|
try:
|
||||||
devices = controller.get_devices('Switch')
|
devices = controller.get_devices('Switch')
|
||||||
except IOError as inst:
|
except RequestException as inst:
|
||||||
# There was a network related error connecting to the vera controller
|
# There was a network related error connecting to the vera controller
|
||||||
_LOGGER.error("Could not find Vera lights: %s", inst)
|
_LOGGER.error("Could not find Vera lights: %s", inst)
|
||||||
return False
|
return False
|
||||||
@ -93,4 +94,3 @@ def setup_platform(hass, config, add_devices_callback, discovery_info=None):
|
|||||||
lights.append(VeraSwitch(device, extra_data))
|
lights.append(VeraSwitch(device, extra_data))
|
||||||
|
|
||||||
add_devices_callback(lights)
|
add_devices_callback(lights)
|
||||||
|
|
||||||
|
@ -48,6 +48,7 @@ it should be set to "true" if you want this device excluded
|
|||||||
"""
|
"""
|
||||||
import logging
|
import logging
|
||||||
import time
|
import time
|
||||||
|
from requests.exceptions import RequestException
|
||||||
|
|
||||||
from homeassistant.helpers import Device
|
from homeassistant.helpers import Device
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
@ -77,7 +78,7 @@ def get_devices(hass, config):
|
|||||||
devices = []
|
devices = []
|
||||||
try:
|
try:
|
||||||
devices = vera_controller.get_devices(categories)
|
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
|
# There was a network related error connecting to the vera controller
|
||||||
_LOGGER.error("Could not find Vera sensors: %s", inst)
|
_LOGGER.error("Could not find Vera sensors: %s", inst)
|
||||||
return False
|
return False
|
||||||
|
@ -50,6 +50,7 @@ it should be set to "true" if you want this device excluded
|
|||||||
"""
|
"""
|
||||||
import logging
|
import logging
|
||||||
import time
|
import time
|
||||||
|
from requests.exceptions import RequestException
|
||||||
|
|
||||||
from homeassistant.helpers import ToggleDevice
|
from homeassistant.helpers import ToggleDevice
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
@ -78,7 +79,7 @@ def get_devices(hass, config):
|
|||||||
devices = []
|
devices = []
|
||||||
try:
|
try:
|
||||||
devices = vera_controller.get_devices(['Switch', 'Armable Sensor'])
|
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
|
# There was a network related error connecting to the vera controller
|
||||||
_LOGGER.error("Could not find Vera switches: %s", inst)
|
_LOGGER.error("Could not find Vera switches: %s", inst)
|
||||||
return False
|
return False
|
||||||
|
Loading…
x
Reference in New Issue
Block a user