mirror of
https://github.com/home-assistant/core.git
synced 2025-08-04 13:15:18 +02:00
async call send_key
This commit is contained in:
@@ -103,7 +103,7 @@ class SamsungTVDevice(MediaPlayerDevice):
|
|||||||
"method": None,
|
"method": None,
|
||||||
"port": port,
|
"port": port,
|
||||||
"host": host,
|
"host": host,
|
||||||
"timeout": None,
|
"timeout": 1,
|
||||||
}
|
}
|
||||||
|
|
||||||
# Select method by port number, mainly for fallback
|
# Select method by port number, mainly for fallback
|
||||||
@@ -114,7 +114,7 @@ class SamsungTVDevice(MediaPlayerDevice):
|
|||||||
|
|
||||||
def update(self):
|
def update(self):
|
||||||
"""Update state of device."""
|
"""Update state of device."""
|
||||||
self.send_key("KEY")
|
self.hass.async_add_executor_job(self.send_key("KEY"))
|
||||||
|
|
||||||
def get_remote(self):
|
def get_remote(self):
|
||||||
"""Create or return a remote control instance."""
|
"""Create or return a remote control instance."""
|
||||||
@@ -250,9 +250,9 @@ class SamsungTVDevice(MediaPlayerDevice):
|
|||||||
self._end_of_power_off = dt_util.utcnow() + timedelta(seconds=15)
|
self._end_of_power_off = dt_util.utcnow() + timedelta(seconds=15)
|
||||||
|
|
||||||
if self._config["method"] == "websocket":
|
if self._config["method"] == "websocket":
|
||||||
self.send_key("KEY_POWER")
|
self.hass.async_add_executor_job(self.send_key("KEY_POWER"))
|
||||||
else:
|
else:
|
||||||
self.send_key("KEY_POWEROFF")
|
self.hass.async_add_executor_job(self.send_key("KEY_POWEROFF"))
|
||||||
# Force closing of remote session to provide instant UI feedback
|
# Force closing of remote session to provide instant UI feedback
|
||||||
try:
|
try:
|
||||||
self.get_remote().close()
|
self.get_remote().close()
|
||||||
@@ -262,15 +262,15 @@ class SamsungTVDevice(MediaPlayerDevice):
|
|||||||
|
|
||||||
def volume_up(self):
|
def volume_up(self):
|
||||||
"""Volume up the media player."""
|
"""Volume up the media player."""
|
||||||
self.send_key("KEY_VOLUP")
|
self.hass.async_add_executor_job(self.send_key("KEY_VOLUP"))
|
||||||
|
|
||||||
def volume_down(self):
|
def volume_down(self):
|
||||||
"""Volume down media player."""
|
"""Volume down media player."""
|
||||||
self.send_key("KEY_VOLDOWN")
|
self.hass.async_add_executor_job(self.send_key("KEY_VOLDOWN"))
|
||||||
|
|
||||||
def mute_volume(self, mute):
|
def mute_volume(self, mute):
|
||||||
"""Send mute command."""
|
"""Send mute command."""
|
||||||
self.send_key("KEY_MUTE")
|
self.hass.async_add_executor_job(self.send_key("KEY_MUTE"))
|
||||||
|
|
||||||
def media_play_pause(self):
|
def media_play_pause(self):
|
||||||
"""Simulate play pause media player."""
|
"""Simulate play pause media player."""
|
||||||
@@ -282,20 +282,20 @@ class SamsungTVDevice(MediaPlayerDevice):
|
|||||||
def media_play(self):
|
def media_play(self):
|
||||||
"""Send play command."""
|
"""Send play command."""
|
||||||
self._playing = True
|
self._playing = True
|
||||||
self.send_key("KEY_PLAY")
|
self.hass.async_add_executor_job(self.send_key("KEY_PLAY"))
|
||||||
|
|
||||||
def media_pause(self):
|
def media_pause(self):
|
||||||
"""Send media pause command to media player."""
|
"""Send media pause command to media player."""
|
||||||
self._playing = False
|
self._playing = False
|
||||||
self.send_key("KEY_PAUSE")
|
self.hass.async_add_executor_job(self.send_key("KEY_PAUSE"))
|
||||||
|
|
||||||
def media_next_track(self):
|
def media_next_track(self):
|
||||||
"""Send next track command."""
|
"""Send next track command."""
|
||||||
self.send_key("KEY_CHUP")
|
self.hass.async_add_executor_job(self.send_key("KEY_CHUP"))
|
||||||
|
|
||||||
def media_previous_track(self):
|
def media_previous_track(self):
|
||||||
"""Send the previous track command."""
|
"""Send the previous track command."""
|
||||||
self.send_key("KEY_CHDOWN")
|
self.hass.async_add_executor_job(self.send_key("KEY_CHDOWN"))
|
||||||
|
|
||||||
async def async_play_media(self, media_type, media_id, **kwargs):
|
async def async_play_media(self, media_type, media_id, **kwargs):
|
||||||
"""Support changing a channel."""
|
"""Support changing a channel."""
|
||||||
@@ -319,13 +319,11 @@ class SamsungTVDevice(MediaPlayerDevice):
|
|||||||
"""Turn the media player on."""
|
"""Turn the media player on."""
|
||||||
if self._on_script:
|
if self._on_script:
|
||||||
await self.hass.async_add_job(self._on_script.async_run())
|
await self.hass.async_add_job(self._on_script.async_run())
|
||||||
else:
|
|
||||||
self.send_key("KEY_POWERON")
|
|
||||||
|
|
||||||
async def async_select_source(self, source):
|
def select_source(self, source):
|
||||||
"""Select input source."""
|
"""Select input source."""
|
||||||
if source not in SOURCES:
|
if source not in SOURCES:
|
||||||
LOGGER.error("Unsupported source")
|
LOGGER.error("Unsupported source")
|
||||||
return
|
return
|
||||||
|
|
||||||
await self.hass.async_add_job(self.send_key, SOURCES[source])
|
self.hass.async_add_executor_job(self.send_key, SOURCES[source])
|
||||||
|
@@ -84,7 +84,7 @@ AUTODETECT_WEBSOCKET = {
|
|||||||
"method": "websocket",
|
"method": "websocket",
|
||||||
"port": None,
|
"port": None,
|
||||||
"host": "fake_auto",
|
"host": "fake_auto",
|
||||||
"timeout": None,
|
"timeout": 1,
|
||||||
}
|
}
|
||||||
AUTODETECT_LEGACY = {
|
AUTODETECT_LEGACY = {
|
||||||
"name": "HomeAssistant",
|
"name": "HomeAssistant",
|
||||||
@@ -93,7 +93,7 @@ AUTODETECT_LEGACY = {
|
|||||||
"method": "legacy",
|
"method": "legacy",
|
||||||
"port": None,
|
"port": None,
|
||||||
"host": "fake_auto",
|
"host": "fake_auto",
|
||||||
"timeout": None,
|
"timeout": 1,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user