mirror of
https://github.com/home-assistant/core.git
synced 2025-07-25 22:27:07 +00:00
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 up
This commit is contained in:
parent
7429b9d87e
commit
47d24759f2
@ -93,15 +93,31 @@ class PjLinkDevice(MediaPlayerDevice):
|
||||
|
||||
def update(self):
|
||||
"""Get the latest state from the device."""
|
||||
from pypjlink.projector import ProjectorError
|
||||
with self.projector() as projector:
|
||||
pwstate = projector.get_power()
|
||||
if pwstate == 'off':
|
||||
self._pwstate = STATE_OFF
|
||||
else:
|
||||
self._pwstate = STATE_ON
|
||||
self._muted = projector.get_mute()[1]
|
||||
self._current_source = \
|
||||
format_input_source(*projector.get_input())
|
||||
try:
|
||||
pwstate = projector.get_power()
|
||||
if pwstate in ('on', 'warm-up'):
|
||||
self._pwstate = STATE_ON
|
||||
else:
|
||||
self._pwstate = STATE_OFF
|
||||
self._muted = projector.get_mute()[1]
|
||||
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
|
||||
def name(self):
|
||||
|
Loading…
x
Reference in New Issue
Block a user