mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
Minor fixes for webostv (#30998)
* restore emulation of play pause toggle * add protection to notify setup * add state check for power off to avoid switching tv back on
This commit is contained in:
parent
053f18d6ce
commit
a634e62dfc
@ -118,6 +118,9 @@ class LgWebOSMediaPlayerEntity(MediaPlayerDevice):
|
||||
self._customize = customize
|
||||
self._on_script = on_script
|
||||
|
||||
# Assume that the TV is not paused
|
||||
self._paused = False
|
||||
|
||||
# Assume that the TV is not muted
|
||||
self._muted = False
|
||||
self._volume = 0
|
||||
@ -290,7 +293,10 @@ class LgWebOSMediaPlayerEntity(MediaPlayerDevice):
|
||||
@cmd
|
||||
async def async_turn_off(self):
|
||||
"""Turn off media player."""
|
||||
await self._client.power_off()
|
||||
|
||||
# in some situations power_off may cause the TV to switch back on
|
||||
if self._state != STATE_OFF:
|
||||
await self._client.power_off()
|
||||
|
||||
async def async_turn_on(self):
|
||||
"""Turn on the media player."""
|
||||
@ -326,8 +332,11 @@ class LgWebOSMediaPlayerEntity(MediaPlayerDevice):
|
||||
|
||||
@cmd
|
||||
async def async_media_play_pause(self):
|
||||
"""Client pause command acts as a play-pause toggle."""
|
||||
await self._client.pause()
|
||||
"""Simulate play pause media player."""
|
||||
if self._paused:
|
||||
await self.async_media_play()
|
||||
else:
|
||||
await self.async_media_pause()
|
||||
|
||||
@cmd
|
||||
async def async_select_source(self, source):
|
||||
@ -379,11 +388,13 @@ class LgWebOSMediaPlayerEntity(MediaPlayerDevice):
|
||||
@cmd
|
||||
async def async_media_play(self):
|
||||
"""Send play command."""
|
||||
self._paused = False
|
||||
await self._client.play()
|
||||
|
||||
@cmd
|
||||
async def async_media_pause(self):
|
||||
"""Send media pause command to media player."""
|
||||
self._paused = True
|
||||
await self._client.pause()
|
||||
|
||||
@cmd
|
||||
|
@ -16,6 +16,9 @@ _LOGGER = logging.getLogger(__name__)
|
||||
async def async_get_service(hass, config, discovery_info=None):
|
||||
"""Return the notify service."""
|
||||
|
||||
if discovery_info is None:
|
||||
return None
|
||||
|
||||
host = discovery_info.get(CONF_HOST)
|
||||
icon_path = discovery_info.get(CONF_ICON)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user