From 543e1a0f9c1888dd5d20165592f13035e2e6295f Mon Sep 17 00:00:00 2001 From: Lasath Fernando Date: Sun, 27 Jun 2021 11:30:49 -0700 Subject: [PATCH] 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. --- homeassistant/components/pjlink/media_player.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/homeassistant/components/pjlink/media_player.py b/homeassistant/components/pjlink/media_player.py index 74536ba8393..3ecd3d26ae1 100644 --- a/homeassistant/components/pjlink/media_player.py +++ b/homeassistant/components/pjlink/media_player.py @@ -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."""