From 2a94c42ceac13252be11474b3b4d7bec90e1ed2c Mon Sep 17 00:00:00 2001 From: Martin Hjelmare Date: Mon, 26 Sep 2022 16:17:39 +0200 Subject: [PATCH] Support VLC 4 pause (#77302) * Support VLC 4 pause * Clean vlc tests types --- homeassistant/components/vlc_telnet/media_player.py | 10 +++++++--- tests/components/vlc_telnet/test_config_flow.py | 4 +--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/homeassistant/components/vlc_telnet/media_player.py b/homeassistant/components/vlc_telnet/media_player.py index ef3406bda28..5d366b6a8aa 100644 --- a/homeassistant/components/vlc_telnet/media_player.py +++ b/homeassistant/components/vlc_telnet/media_player.py @@ -260,7 +260,12 @@ class VlcDevice(MediaPlayerEntity): @catch_vlc_errors async def async_media_play(self) -> None: """Send play command.""" - await self._vlc.play() + status = await self._vlc.status() + if status.state == "paused": + # If already paused, play by toggling pause. + await self._vlc.pause() + else: + await self._vlc.play() self._attr_state = MediaPlayerState.PLAYING @catch_vlc_errors @@ -268,8 +273,7 @@ class VlcDevice(MediaPlayerEntity): """Send pause command.""" status = await self._vlc.status() if status.state != "paused": - # Make sure we're not already paused since VLCTelnet.pause() toggles - # pause. + # Make sure we're not already paused as pausing again will unpause. await self._vlc.pause() self._attr_state = MediaPlayerState.PAUSED diff --git a/tests/components/vlc_telnet/test_config_flow.py b/tests/components/vlc_telnet/test_config_flow.py index 66ca5c2cb20..5e712c71b24 100644 --- a/tests/components/vlc_telnet/test_config_flow.py +++ b/tests/components/vlc_telnet/test_config_flow.py @@ -15,8 +15,6 @@ from homeassistant.data_entry_flow import FlowResultType from tests.common import MockConfigEntry -# mypy: allow-untyped-calls - @pytest.mark.parametrize( "input_data, entry_data", @@ -139,7 +137,7 @@ async def test_errors( async def test_reauth_flow(hass: HomeAssistant) -> None: """Test successful reauth flow.""" - entry_data = { + entry_data: dict[str, Any] = { "password": "old-password", "host": "1.1.1.1", "port": 8888,