diff --git a/homeassistant/components/webostv/media_player.py b/homeassistant/components/webostv/media_player.py index 5e58cdf7a2f..4652d6385c1 100644 --- a/homeassistant/components/webostv/media_player.py +++ b/homeassistant/components/webostv/media_player.py @@ -30,8 +30,7 @@ from homeassistant.const import ( CONF_NAME, ENTITY_MATCH_ALL, STATE_OFF, - STATE_PAUSED, - STATE_PLAYING, + STATE_ON, ) from homeassistant.helpers.dispatcher import async_dispatcher_connect from homeassistant.helpers.script import Script @@ -121,8 +120,6 @@ class LgWebOSMediaPlayerEntity(MediaPlayerDevice): # Assume that the TV is not muted self._muted = False - # Assume that the TV is in Play mode - self._playing = True self._volume = 0 self._current_source = None self._current_source_id = None @@ -172,7 +169,7 @@ class LgWebOSMediaPlayerEntity(MediaPlayerDevice): if self._current_source_id == "": self._state = STATE_OFF else: - self._state = STATE_PLAYING + self._state = STATE_ON self.update_sources() @@ -325,16 +322,12 @@ class LgWebOSMediaPlayerEntity(MediaPlayerDevice): @cmd async def async_mute_volume(self, mute): """Send mute command.""" - self._muted = mute await self._client.set_mute(mute) @cmd async def async_media_play_pause(self): - """Simulate play pause media player.""" - if self._playing: - await self.media_pause() - else: - await self.media_play() + """Client pause command acts as a play-pause toggle.""" + await self._client.pause() @cmd async def async_select_source(self, source): @@ -343,12 +336,9 @@ class LgWebOSMediaPlayerEntity(MediaPlayerDevice): if source_dict is None: _LOGGER.warning("Source %s not found for %s", source, self.name) return - self._current_source_id = source_dict["id"] if source_dict.get("title"): - self._current_source = source_dict["title"] await self._client.launch_app(source_dict["id"]) elif source_dict.get("label"): - self._current_source = source_dict["label"] await self._client.set_input(source_dict["id"]) @cmd @@ -389,15 +379,11 @@ class LgWebOSMediaPlayerEntity(MediaPlayerDevice): @cmd async def async_media_play(self): """Send play command.""" - self._playing = True - self._state = STATE_PLAYING await self._client.play() @cmd async def async_media_pause(self): """Send media pause command to media player.""" - self._playing = False - self._state = STATE_PAUSED await self._client.pause() @cmd diff --git a/tests/components/webostv/test_media_player.py b/tests/components/webostv/test_media_player.py index 4dcda9eb908..b0be238f971 100644 --- a/tests/components/webostv/test_media_player.py +++ b/tests/components/webostv/test_media_player.py @@ -21,6 +21,7 @@ from homeassistant.const import ( CONF_HOST, CONF_NAME, SERVICE_VOLUME_MUTE, + STATE_ON, ) from homeassistant.setup import async_setup_component @@ -78,7 +79,7 @@ async def test_select_source_with_empty_source_list(hass, client): await hass.services.async_call(media_player.DOMAIN, SERVICE_SELECT_SOURCE, data) await hass.async_block_till_done() - assert hass.states.is_state(ENTITY_ID, "playing") + assert hass.states.is_state(ENTITY_ID, STATE_ON) client.launch_app.assert_not_called() client.set_input.assert_not_called()