mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
Update media_player to use async_add_executor_job (#41459)
This commit is contained in:
parent
dfc656a2c6
commit
740d15e41d
@ -523,7 +523,7 @@ class MediaPlayerEntity(Entity):
|
||||
|
||||
async def async_turn_on(self):
|
||||
"""Turn the media player on."""
|
||||
await self.hass.async_add_job(self.turn_on)
|
||||
await self.hass.async_add_executor_job(self.turn_on)
|
||||
|
||||
def turn_off(self):
|
||||
"""Turn the media player off."""
|
||||
@ -531,7 +531,7 @@ class MediaPlayerEntity(Entity):
|
||||
|
||||
async def async_turn_off(self):
|
||||
"""Turn the media player off."""
|
||||
await self.hass.async_add_job(self.turn_off)
|
||||
await self.hass.async_add_executor_job(self.turn_off)
|
||||
|
||||
def mute_volume(self, mute):
|
||||
"""Mute the volume."""
|
||||
@ -539,7 +539,7 @@ class MediaPlayerEntity(Entity):
|
||||
|
||||
async def async_mute_volume(self, mute):
|
||||
"""Mute the volume."""
|
||||
await self.hass.async_add_job(self.mute_volume, mute)
|
||||
await self.hass.async_add_executor_job(self.mute_volume, mute)
|
||||
|
||||
def set_volume_level(self, volume):
|
||||
"""Set volume level, range 0..1."""
|
||||
@ -547,7 +547,7 @@ class MediaPlayerEntity(Entity):
|
||||
|
||||
async def async_set_volume_level(self, volume):
|
||||
"""Set volume level, range 0..1."""
|
||||
await self.hass.async_add_job(self.set_volume_level, volume)
|
||||
await self.hass.async_add_executor_job(self.set_volume_level, volume)
|
||||
|
||||
def media_play(self):
|
||||
"""Send play command."""
|
||||
@ -555,7 +555,7 @@ class MediaPlayerEntity(Entity):
|
||||
|
||||
async def async_media_play(self):
|
||||
"""Send play command."""
|
||||
await self.hass.async_add_job(self.media_play)
|
||||
await self.hass.async_add_executor_job(self.media_play)
|
||||
|
||||
def media_pause(self):
|
||||
"""Send pause command."""
|
||||
@ -563,7 +563,7 @@ class MediaPlayerEntity(Entity):
|
||||
|
||||
async def async_media_pause(self):
|
||||
"""Send pause command."""
|
||||
await self.hass.async_add_job(self.media_pause)
|
||||
await self.hass.async_add_executor_job(self.media_pause)
|
||||
|
||||
def media_stop(self):
|
||||
"""Send stop command."""
|
||||
@ -571,7 +571,7 @@ class MediaPlayerEntity(Entity):
|
||||
|
||||
async def async_media_stop(self):
|
||||
"""Send stop command."""
|
||||
await self.hass.async_add_job(self.media_stop)
|
||||
await self.hass.async_add_executor_job(self.media_stop)
|
||||
|
||||
def media_previous_track(self):
|
||||
"""Send previous track command."""
|
||||
@ -579,7 +579,7 @@ class MediaPlayerEntity(Entity):
|
||||
|
||||
async def async_media_previous_track(self):
|
||||
"""Send previous track command."""
|
||||
await self.hass.async_add_job(self.media_previous_track)
|
||||
await self.hass.async_add_executor_job(self.media_previous_track)
|
||||
|
||||
def media_next_track(self):
|
||||
"""Send next track command."""
|
||||
@ -587,7 +587,7 @@ class MediaPlayerEntity(Entity):
|
||||
|
||||
async def async_media_next_track(self):
|
||||
"""Send next track command."""
|
||||
await self.hass.async_add_job(self.media_next_track)
|
||||
await self.hass.async_add_executor_job(self.media_next_track)
|
||||
|
||||
def media_seek(self, position):
|
||||
"""Send seek command."""
|
||||
@ -595,7 +595,7 @@ class MediaPlayerEntity(Entity):
|
||||
|
||||
async def async_media_seek(self, position):
|
||||
"""Send seek command."""
|
||||
await self.hass.async_add_job(self.media_seek, position)
|
||||
await self.hass.async_add_executor_job(self.media_seek, position)
|
||||
|
||||
def play_media(self, media_type, media_id, **kwargs):
|
||||
"""Play a piece of media."""
|
||||
@ -603,7 +603,7 @@ class MediaPlayerEntity(Entity):
|
||||
|
||||
async def async_play_media(self, media_type, media_id, **kwargs):
|
||||
"""Play a piece of media."""
|
||||
await self.hass.async_add_job(
|
||||
await self.hass.async_add_executor_job(
|
||||
ft.partial(self.play_media, media_type, media_id, **kwargs)
|
||||
)
|
||||
|
||||
@ -613,7 +613,7 @@ class MediaPlayerEntity(Entity):
|
||||
|
||||
async def async_select_source(self, source):
|
||||
"""Select input source."""
|
||||
await self.hass.async_add_job(self.select_source, source)
|
||||
await self.hass.async_add_executor_job(self.select_source, source)
|
||||
|
||||
def select_sound_mode(self, sound_mode):
|
||||
"""Select sound mode."""
|
||||
@ -621,7 +621,7 @@ class MediaPlayerEntity(Entity):
|
||||
|
||||
async def async_select_sound_mode(self, sound_mode):
|
||||
"""Select sound mode."""
|
||||
await self.hass.async_add_job(self.select_sound_mode, sound_mode)
|
||||
await self.hass.async_add_executor_job(self.select_sound_mode, sound_mode)
|
||||
|
||||
def clear_playlist(self):
|
||||
"""Clear players playlist."""
|
||||
@ -629,7 +629,7 @@ class MediaPlayerEntity(Entity):
|
||||
|
||||
async def async_clear_playlist(self):
|
||||
"""Clear players playlist."""
|
||||
await self.hass.async_add_job(self.clear_playlist)
|
||||
await self.hass.async_add_executor_job(self.clear_playlist)
|
||||
|
||||
def set_shuffle(self, shuffle):
|
||||
"""Enable/disable shuffle mode."""
|
||||
@ -637,7 +637,7 @@ class MediaPlayerEntity(Entity):
|
||||
|
||||
async def async_set_shuffle(self, shuffle):
|
||||
"""Enable/disable shuffle mode."""
|
||||
await self.hass.async_add_job(self.set_shuffle, shuffle)
|
||||
await self.hass.async_add_executor_job(self.set_shuffle, shuffle)
|
||||
|
||||
# No need to overwrite these.
|
||||
@property
|
||||
@ -709,7 +709,7 @@ class MediaPlayerEntity(Entity):
|
||||
"""Toggle the power on the media player."""
|
||||
if hasattr(self, "toggle"):
|
||||
# pylint: disable=no-member
|
||||
await self.hass.async_add_job(self.toggle)
|
||||
await self.hass.async_add_executor_job(self.toggle)
|
||||
return
|
||||
|
||||
if self.state in [STATE_OFF, STATE_IDLE]:
|
||||
@ -724,7 +724,7 @@ class MediaPlayerEntity(Entity):
|
||||
"""
|
||||
if hasattr(self, "volume_up"):
|
||||
# pylint: disable=no-member
|
||||
await self.hass.async_add_job(self.volume_up)
|
||||
await self.hass.async_add_executor_job(self.volume_up)
|
||||
return
|
||||
|
||||
if self.volume_level < 1 and self.supported_features & SUPPORT_VOLUME_SET:
|
||||
@ -737,7 +737,7 @@ class MediaPlayerEntity(Entity):
|
||||
"""
|
||||
if hasattr(self, "volume_down"):
|
||||
# pylint: disable=no-member
|
||||
await self.hass.async_add_job(self.volume_down)
|
||||
await self.hass.async_add_executor_job(self.volume_down)
|
||||
return
|
||||
|
||||
if self.volume_level > 0 and self.supported_features & SUPPORT_VOLUME_SET:
|
||||
@ -747,7 +747,7 @@ class MediaPlayerEntity(Entity):
|
||||
"""Play or pause the media player."""
|
||||
if hasattr(self, "media_play_pause"):
|
||||
# pylint: disable=no-member
|
||||
await self.hass.async_add_job(self.media_play_pause)
|
||||
await self.hass.async_add_executor_job(self.media_play_pause)
|
||||
return
|
||||
|
||||
if self.state == STATE_PLAYING:
|
||||
|
Loading…
x
Reference in New Issue
Block a user