1
mirror of https://github.com/home-assistant/core synced 2024-09-15 17:29:45 +02:00

Fixes #3511 - handle multiple return values (#4659)

This commit is contained in:
Brandon Weeks 2016-12-01 18:28:52 -08:00 committed by Paulus Schoutsen
parent 279f82acc4
commit f09b888a8a

View File

@ -62,7 +62,14 @@ class DenonDevice(MediaPlayerDevice):
def telnet_request(cls, telnet, command):
"""Execute `command` and return the response."""
telnet.write(command.encode('ASCII') + b'\r')
return telnet.read_until(b'\r', timeout=0.2).decode('ASCII').strip()
lines = []
while True:
line = telnet.read_until(b'\r', timeout=0.2)
if not line:
break
lines.append(line.decode('ASCII').strip())
return lines[0]
def telnet_command(self, command):
"""Establish a telnet connection and sends `command`."""
@ -79,9 +86,6 @@ class DenonDevice(MediaPlayerDevice):
return False
self._pwstate = self.telnet_request(telnet, 'PW?')
# PW? sends also SISTATUS, which is not interesting
telnet.read_until(b"\r", timeout=0.2)
volume_str = self.telnet_request(telnet, 'MV?')[len('MV'):]
self._volume = int(volume_str) / 60
self._muted = (self.telnet_request(telnet, 'MU?') == 'MUON')