From 957f42b716b66857e9739bad89d359542bc47829 Mon Sep 17 00:00:00 2001 From: David McClosky Date: Fri, 19 Feb 2021 21:32:36 -0500 Subject: [PATCH 1/5] Add volume step support to vlc_telnet Cleanup: sort SUPPORT_VLC elements. --- .../components/vlc_telnet/media_player.py | 38 +++++++++++++++---- 1 file changed, 30 insertions(+), 8 deletions(-) diff --git a/homeassistant/components/vlc_telnet/media_player.py b/homeassistant/components/vlc_telnet/media_player.py index 68b3c373c7add3..1dce6588e52337 100644 --- a/homeassistant/components/vlc_telnet/media_player.py +++ b/homeassistant/components/vlc_telnet/media_player.py @@ -24,6 +24,7 @@ SUPPORT_STOP, SUPPORT_VOLUME_MUTE, SUPPORT_VOLUME_SET, + SUPPORT_VOLUME_STEP, ) from homeassistant.const import ( CONF_HOST, @@ -46,17 +47,18 @@ MAX_VOLUME = 500 SUPPORT_VLC = ( - SUPPORT_PAUSE - | SUPPORT_SEEK - | SUPPORT_VOLUME_SET - | SUPPORT_VOLUME_MUTE - | SUPPORT_PREVIOUS_TRACK + SUPPORT_CLEAR_PLAYLIST | SUPPORT_NEXT_TRACK - | SUPPORT_PLAY_MEDIA - | SUPPORT_STOP - | SUPPORT_CLEAR_PLAYLIST + | SUPPORT_PAUSE | SUPPORT_PLAY + | SUPPORT_PLAY_MEDIA + | SUPPORT_PREVIOUS_TRACK + | SUPPORT_SEEK | SUPPORT_SHUFFLE_SET + | SUPPORT_STOP + | SUPPORT_VOLUME_MUTE + | SUPPORT_VOLUME_SET + | SUPPORT_VOLUME_STEP ) PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend( { @@ -238,6 +240,26 @@ def set_volume_level(self, volume): self._vlc.set_volume(volume * MAX_VOLUME) self._volume = volume + def volume_up(self): + """Service to send VLC the command for volume up.""" + if self._volume is None: + return + + current_volume = self._volume + if current_volume < MAX_VOLUME: + new_volume = min(current_volume + 0.05, MAX_VOLUME) + self.set_volume_level(new_volume) + + def volume_down(self): + """Service to send VLC the command for volume down.""" + if self._volume is None: + return + + current_volume = self._volume + if current_volume > 0: + new_volume = max(current_volume - 0.05, 0) + self.set_volume_level(new_volume) + def media_play(self): """Send play command.""" self._vlc.play() From 482cc1a3299d0673d1d573d7ccd640ec47a4fa94 Mon Sep 17 00:00:00 2001 From: David McClosky Date: Fri, 19 Feb 2021 22:39:01 -0500 Subject: [PATCH 2/5] Fix maximum volume rank check --- homeassistant/components/vlc_telnet/media_player.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/vlc_telnet/media_player.py b/homeassistant/components/vlc_telnet/media_player.py index 1dce6588e52337..306a5166593bcd 100644 --- a/homeassistant/components/vlc_telnet/media_player.py +++ b/homeassistant/components/vlc_telnet/media_player.py @@ -246,8 +246,8 @@ def volume_up(self): return current_volume = self._volume - if current_volume < MAX_VOLUME: - new_volume = min(current_volume + 0.05, MAX_VOLUME) + if current_volume < 1.0: + new_volume = min(current_volume + 0.05, 1.0) self.set_volume_level(new_volume) def volume_down(self): From c51b850bb9f223a38a308b4c8a4a463c4b34b680 Mon Sep 17 00:00:00 2001 From: David McClosky Date: Sun, 28 Feb 2021 14:26:11 -0500 Subject: [PATCH 3/5] Remove methods covered by base media player entity --- .../components/vlc_telnet/media_player.py | 20 ------------------- 1 file changed, 20 deletions(-) diff --git a/homeassistant/components/vlc_telnet/media_player.py b/homeassistant/components/vlc_telnet/media_player.py index 306a5166593bcd..023919807a18e0 100644 --- a/homeassistant/components/vlc_telnet/media_player.py +++ b/homeassistant/components/vlc_telnet/media_player.py @@ -240,26 +240,6 @@ def set_volume_level(self, volume): self._vlc.set_volume(volume * MAX_VOLUME) self._volume = volume - def volume_up(self): - """Service to send VLC the command for volume up.""" - if self._volume is None: - return - - current_volume = self._volume - if current_volume < 1.0: - new_volume = min(current_volume + 0.05, 1.0) - self.set_volume_level(new_volume) - - def volume_down(self): - """Service to send VLC the command for volume down.""" - if self._volume is None: - return - - current_volume = self._volume - if current_volume > 0: - new_volume = max(current_volume - 0.05, 0) - self.set_volume_level(new_volume) - def media_play(self): """Send play command.""" self._vlc.play() From a4b0c6cc505ac278aba0f1d9c094f6c4823daefc Mon Sep 17 00:00:00 2001 From: David McClosky Date: Thu, 4 Mar 2021 20:02:54 -0500 Subject: [PATCH 4/5] Remove SUPPORT_VOLUME_STEP since unnecessary The base media entity implementation works fine. --- homeassistant/components/vlc_telnet/media_player.py | 1 - 1 file changed, 1 deletion(-) diff --git a/homeassistant/components/vlc_telnet/media_player.py b/homeassistant/components/vlc_telnet/media_player.py index 023919807a18e0..d80e3cf270c5aa 100644 --- a/homeassistant/components/vlc_telnet/media_player.py +++ b/homeassistant/components/vlc_telnet/media_player.py @@ -58,7 +58,6 @@ | SUPPORT_STOP | SUPPORT_VOLUME_MUTE | SUPPORT_VOLUME_SET - | SUPPORT_VOLUME_STEP ) PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend( { From 605695411216faf53d0a92ddbf494af8778cb0ad Mon Sep 17 00:00:00 2001 From: David McClosky Date: Thu, 4 Mar 2021 20:08:39 -0500 Subject: [PATCH 5/5] Remove SUPPORT_VOLUME_STEP import too --- homeassistant/components/vlc_telnet/media_player.py | 1 - 1 file changed, 1 deletion(-) diff --git a/homeassistant/components/vlc_telnet/media_player.py b/homeassistant/components/vlc_telnet/media_player.py index d80e3cf270c5aa..8f557b1e0a4509 100644 --- a/homeassistant/components/vlc_telnet/media_player.py +++ b/homeassistant/components/vlc_telnet/media_player.py @@ -24,7 +24,6 @@ SUPPORT_STOP, SUPPORT_VOLUME_MUTE, SUPPORT_VOLUME_SET, - SUPPORT_VOLUME_STEP, ) from homeassistant.const import ( CONF_HOST,