parent
279f82acc4
commit
f09b888a8a
1 changed files with 8 additions and 4 deletions
|
@ -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')
|
||||
|
|
Loading…
Add table
Reference in a new issue