1
mirror of https://github.com/home-assistant/core synced 2024-10-01 05:30:36 +02:00

Make PjLink power toggle more robust (#51821)

Occasionally, this integration misses events (or maybe they never get sent) from the projector and gets "stuck" in the wrong power state.
Currently, this prevents this integration from changing the power state as it thinks its already in the correct state. Only way to resolve this is to reboot home assistant.

This PR makes it a little more resilient by attempting to send the correct command even when it thinks it's already in the correct state.
This commit is contained in:
Lasath Fernando 2021-06-27 11:30:49 -07:00 committed by GitHub
parent aececdfeb9
commit 543e1a0f9c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -157,15 +157,13 @@ class PjLinkDevice(MediaPlayerEntity):
def turn_off(self):
"""Turn projector off."""
if self._pwstate == STATE_ON:
with self.projector() as projector:
projector.set_power("off")
with self.projector() as projector:
projector.set_power("off")
def turn_on(self):
"""Turn projector on."""
if self._pwstate == STATE_OFF:
with self.projector() as projector:
projector.set_power("on")
with self.projector() as projector:
projector.set_power("on")
def mute_volume(self, mute):
"""Mute (true) of unmute (false) media player."""