parent
164e953e8c
commit
53048f71a0
1 changed files with 7 additions and 8 deletions
|
@ -85,14 +85,13 @@ class PioneerDevice(MediaPlayerDevice):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def telnet_command(self, command):
|
def telnet_command(self, command):
|
||||||
"""Establish a telnet connection and sends `command`."""
|
"""Establish a telnet connection and sends command."""
|
||||||
try:
|
try:
|
||||||
try:
|
try:
|
||||||
telnet = telnetlib.Telnet(self._host,
|
telnet = telnetlib.Telnet(
|
||||||
self._port,
|
self._host, self._port, self._timeout)
|
||||||
self._timeout)
|
except (ConnectionRefusedError, OSError):
|
||||||
except ConnectionRefusedError:
|
_LOGGER.warning("Pioneer %s refused connection", self._name)
|
||||||
_LOGGER.debug("Pioneer %s refused connection", self._name)
|
|
||||||
return
|
return
|
||||||
telnet.write(command.encode("ASCII") + b"\r")
|
telnet.write(command.encode("ASCII") + b"\r")
|
||||||
telnet.read_very_eager() # skip response
|
telnet.read_very_eager() # skip response
|
||||||
|
@ -105,8 +104,8 @@ class PioneerDevice(MediaPlayerDevice):
|
||||||
"""Get the latest details from the device."""
|
"""Get the latest details from the device."""
|
||||||
try:
|
try:
|
||||||
telnet = telnetlib.Telnet(self._host, self._port, self._timeout)
|
telnet = telnetlib.Telnet(self._host, self._port, self._timeout)
|
||||||
except ConnectionRefusedError:
|
except (ConnectionRefusedError, OSError):
|
||||||
_LOGGER.debug("Pioneer %s refused connection", self._name)
|
_LOGGER.warning("Pioneer %s refused connection", self._name)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
pwstate = self.telnet_request(telnet, "?P", "PWR")
|
pwstate = self.telnet_request(telnet, "?P", "PWR")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue