From c2dc940819b032e5cf3d4579e7f7e3a5c85f731a Mon Sep 17 00:00:00 2001 From: Philipp Schmitt <pschmitt@users.noreply.github.com> Date: Fri, 17 Feb 2017 21:40:20 +0100 Subject: [PATCH] Update liveboxplaytv and catch connection errors (#6056) * Update liveboxplaytv and catch connection errors * Implement @pvizeli's suggestion * lint --- .../components/media_player/liveboxplaytv.py | 13 ++++++++++--- requirements_all.txt | 2 +- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/homeassistant/components/media_player/liveboxplaytv.py b/homeassistant/components/media_player/liveboxplaytv.py index b36d52a161c..093a53786be 100644 --- a/homeassistant/components/media_player/liveboxplaytv.py +++ b/homeassistant/components/media_player/liveboxplaytv.py @@ -21,7 +21,7 @@ from homeassistant.const import ( STATE_PAUSED, STATE_UNKNOWN, CONF_NAME) import homeassistant.helpers.config_validation as cv -REQUIREMENTS = ['liveboxplaytv==1.4.7'] +REQUIREMENTS = ['liveboxplaytv==1.4.8'] _LOGGER = logging.getLogger(__name__) @@ -50,7 +50,15 @@ def setup_platform(hass, config, add_devices, discovery_info=None): port = config.get(CONF_PORT) name = config.get(CONF_NAME) - add_devices([LiveboxPlayTvDevice(host, port, name)], True) + livebox_devices = [] + + try: + device = LiveboxPlayTvDevice(host, port, name) + livebox_devices.append(device) + except IOError: + _LOGGER.error('Failed to connect to Livebox Play TV at %s:%s. ' + 'Please check your configuration.', host, port) + add_devices(livebox_devices, True) class LiveboxPlayTvDevice(MediaPlayerDevice): @@ -62,7 +70,6 @@ class LiveboxPlayTvDevice(MediaPlayerDevice): self._client = LiveboxPlayTv(host, port) # Assume that the appliance is not muted self._muted = False - # Assume that the TV is in Play mode self._name = name self._current_source = None self._state = STATE_UNKNOWN diff --git a/requirements_all.txt b/requirements_all.txt index 2da5d549362..cfe45f4d608 100755 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -322,7 +322,7 @@ liffylights==0.9.4 limitlessled==1.0.4 # homeassistant.components.media_player.liveboxplaytv -liveboxplaytv==1.4.7 +liveboxplaytv==1.4.8 # homeassistant.components.notify.matrix matrix-client==0.0.5 -- GitLab