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._customize = customize
|
||||||
self._on_script = on_script
|
self._on_script = on_script
|
||||||
|
|
||||||
|
# Assume that the TV is not paused
|
||||||
|
self._paused = False
|
||||||
|
|
||||||
# Assume that the TV is not muted
|
# Assume that the TV is not muted
|
||||||
self._muted = False
|
self._muted = False
|
||||||
self._volume = 0
|
self._volume = 0
|
||||||
@ -290,6 +293,9 @@ class LgWebOSMediaPlayerEntity(MediaPlayerDevice):
|
|||||||
@cmd
|
@cmd
|
||||||
async def async_turn_off(self):
|
async def async_turn_off(self):
|
||||||
"""Turn off media player."""
|
"""Turn off media player."""
|
||||||
|
|
||||||
|
# in some situations power_off may cause the TV to switch back on
|
||||||
|
if self._state != STATE_OFF:
|
||||||
await self._client.power_off()
|
await self._client.power_off()
|
||||||
|
|
||||||
async def async_turn_on(self):
|
async def async_turn_on(self):
|
||||||
@ -326,8 +332,11 @@ class LgWebOSMediaPlayerEntity(MediaPlayerDevice):
|
|||||||
|
|
||||||
@cmd
|
@cmd
|
||||||
async def async_media_play_pause(self):
|
async def async_media_play_pause(self):
|
||||||
"""Client pause command acts as a play-pause toggle."""
|
"""Simulate play pause media player."""
|
||||||
await self._client.pause()
|
if self._paused:
|
||||||
|
await self.async_media_play()
|
||||||
|
else:
|
||||||
|
await self.async_media_pause()
|
||||||
|
|
||||||
@cmd
|
@cmd
|
||||||
async def async_select_source(self, source):
|
async def async_select_source(self, source):
|
||||||
@ -379,11 +388,13 @@ class LgWebOSMediaPlayerEntity(MediaPlayerDevice):
|
|||||||
@cmd
|
@cmd
|
||||||
async def async_media_play(self):
|
async def async_media_play(self):
|
||||||
"""Send play command."""
|
"""Send play command."""
|
||||||
|
self._paused = False
|
||||||
await self._client.play()
|
await self._client.play()
|
||||||
|
|
||||||
@cmd
|
@cmd
|
||||||
async def async_media_pause(self):
|
async def async_media_pause(self):
|
||||||
"""Send media pause command to media player."""
|
"""Send media pause command to media player."""
|
||||||
|
self._paused = True
|
||||||
await self._client.pause()
|
await self._client.pause()
|
||||||
|
|
||||||
@cmd
|
@cmd
|
||||||
|
@ -16,6 +16,9 @@ _LOGGER = logging.getLogger(__name__)
|
|||||||
async def async_get_service(hass, config, discovery_info=None):
|
async def async_get_service(hass, config, discovery_info=None):
|
||||||
"""Return the notify service."""
|
"""Return the notify service."""
|
||||||
|
|
||||||
|
if discovery_info is None:
|
||||||
|
return None
|
||||||
|
|
||||||
host = discovery_info.get(CONF_HOST)
|
host = discovery_info.get(CONF_HOST)
|
||||||
icon_path = discovery_info.get(CONF_ICON)
|
icon_path = discovery_info.get(CONF_ICON)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user