From 60ca79ce352f722ff27b7b40cd57b7e4273fcd2c Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Mon, 31 Jul 2017 17:58:13 +0200 Subject: [PATCH] Supress exception if host is not available (fixes #8684) (#8732) --- homeassistant/components/media_player/pioneer.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/homeassistant/components/media_player/pioneer.py b/homeassistant/components/media_player/pioneer.py index ba08003b9bf01e..25424224c703ec 100644 --- a/homeassistant/components/media_player/pioneer.py +++ b/homeassistant/components/media_player/pioneer.py @@ -85,14 +85,13 @@ def telnet_request(cls, telnet, command, expected_prefix): return None def telnet_command(self, command): - """Establish a telnet connection and sends `command`.""" + """Establish a telnet connection and sends command.""" try: try: - telnet = telnetlib.Telnet(self._host, - self._port, - self._timeout) - except ConnectionRefusedError: - _LOGGER.debug("Pioneer %s refused connection", self._name) + telnet = telnetlib.Telnet( + self._host, self._port, self._timeout) + except (ConnectionRefusedError, OSError): + _LOGGER.warning("Pioneer %s refused connection", self._name) return telnet.write(command.encode("ASCII") + b"\r") telnet.read_very_eager() # skip response @@ -105,8 +104,8 @@ def update(self): """Get the latest details from the device.""" try: telnet = telnetlib.Telnet(self._host, self._port, self._timeout) - except ConnectionRefusedError: - _LOGGER.debug("Pioneer %s refused connection", self._name) + except (ConnectionRefusedError, OSError): + _LOGGER.warning("Pioneer %s refused connection", self._name) return False pwstate = self.telnet_request(telnet, "?P", "PWR")