Fix pjlink issue (#20510)
* Fix issue #16606 Some projectors do not respond to pjlink requests during a short period after the status changes or when its in standby, resulting in pypjlink2 throwing an error. This fix catches these errors. Furthermore, only the status 'on' and 'warm-up' is interpreted as switched on, because 'cooling' is actually a switched off status. * Update pjlink.py Improved error handling * Update pjlink.py Improved error handling * Update pjlink.py Clean uppull/20794/head
parent
0400e29f7a
commit
557b745053
|
@ -93,15 +93,31 @@ class PjLinkDevice(MediaPlayerDevice):
|
||||||
|
|
||||||
def update(self):
|
def update(self):
|
||||||
"""Get the latest state from the device."""
|
"""Get the latest state from the device."""
|
||||||
|
from pypjlink.projector import ProjectorError
|
||||||
with self.projector() as projector:
|
with self.projector() as projector:
|
||||||
pwstate = projector.get_power()
|
try:
|
||||||
if pwstate == 'off':
|
pwstate = projector.get_power()
|
||||||
self._pwstate = STATE_OFF
|
if pwstate in ('on', 'warm-up'):
|
||||||
else:
|
self._pwstate = STATE_ON
|
||||||
self._pwstate = STATE_ON
|
else:
|
||||||
self._muted = projector.get_mute()[1]
|
self._pwstate = STATE_OFF
|
||||||
self._current_source = \
|
self._muted = projector.get_mute()[1]
|
||||||
format_input_source(*projector.get_input())
|
self._current_source = \
|
||||||
|
format_input_source(*projector.get_input())
|
||||||
|
except KeyError as err:
|
||||||
|
if str(err) == "'OK'":
|
||||||
|
self._pwstate = STATE_OFF
|
||||||
|
self._muted = False
|
||||||
|
self._current_source = None
|
||||||
|
else:
|
||||||
|
raise
|
||||||
|
except ProjectorError as err:
|
||||||
|
if str(err) == 'unavailable time':
|
||||||
|
self._pwstate = STATE_OFF
|
||||||
|
self._muted = False
|
||||||
|
self._current_source = None
|
||||||
|
else:
|
||||||
|
raise
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
|
|
Loading…
Reference in New Issue