Wemo custom ports and network errors handling (#14516)

* Update wemo component

* Support custom ports in static addresses
* Handle device_from_description exceptions
* Process static addresses before doing discovery
* Fail on inaccessable static address
* str.format instead of old formatting

* Validate static host[:port] earlier

* Fix comment formatting

* slice looks ambiguous in the log, keep voluptuous exception path intact
This commit is contained in:
Max Prokhorov authored and Aaron Bach committed 2018-08-16 08:14:54 -06:00
1 parent 1ff1639cef
commit 2a210607d3
4 files changed
+87 -17

No files matched your search

@@ -5,8 +5,10 @@ For more details about this component, please refer to the documentation at
https://home-assistant.io/components/binary_sensor.wemo/
"""
import logging
import requests
from homeassistant.components.binary_sensor import BinarySensorDevice
from homeassistant.exceptions import PlatformNotReady
DEPENDENCIES = ['wemo']
@@ -20,7 +22,13 @@ def setup_platform(hass, config, add_devices_callback, discovery_info=None):
if discovery_info is not None:
location = discovery_info['ssdp_description']
mac = discovery_info['mac_address']
device = discovery.device_from_description(location, mac)
try:
device = discovery.device_from_description(location, mac)
except (requests.exceptions.ConnectionError,
requests.exceptions.Timeout) as err:
_LOGGER.error('Unable to access %s (%s)', location, err)
raise PlatformNotReady
if device:
add_devices_callback([WemoBinarySensor(hass, device)])