diff --git a/homeassistant/components/webostv/media_player.py b/homeassistant/components/webostv/media_player.py index b7c8a416870..c523c068bcc 100644 --- a/homeassistant/components/webostv/media_player.py +++ b/homeassistant/components/webostv/media_player.py @@ -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 diff --git a/homeassistant/components/webostv/notify.py b/homeassistant/components/webostv/notify.py index e75fafbfe23..ece76b5ed32 100644 --- a/homeassistant/components/webostv/notify.py +++ b/homeassistant/components/webostv/notify.py @@ -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)