Skip to content

Commit

Permalink
Fix SamsungTV sendkey when not connected (home-assistant#55723)
Browse files Browse the repository at this point in the history
  • Loading branch information
chemelli74 authored Sep 4, 2021
1 parent 715ce31 commit d39b861
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions homeassistant/components/samsungtv/bridge.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,8 @@ def _get_remote(self, avoid_open: bool = False):

def _send_key(self, key):
"""Send the key using legacy protocol."""
self._get_remote().control(key)
if remote := self._get_remote():
remote.control(key)

def stop(self):
"""Stop Bridge."""
Expand Down Expand Up @@ -315,7 +316,8 @@ def _send_key(self, key):
"""Send the key using websocket protocol."""
if key == "KEY_POWEROFF":
key = "KEY_POWER"
self._get_remote().send_key(key)
if remote := self._get_remote():
remote.send_key(key)

def _get_remote(self, avoid_open: bool = False):
"""Create or return a remote control instance."""
Expand Down

0 comments on commit d39b861

Please sign in to comment.