From 4844477d3a50179708275d169fb86ac6340b5566 Mon Sep 17 00:00:00 2001 From: Jeff Irion Date: Wed, 10 Jul 2019 15:58:29 -0700 Subject: [PATCH] Make sure volume level is valid when incrementing/decrementing (#25061) * Make sure volume level is not None before incrementing/decrementing * Pass linting checks --- homeassistant/components/vizio/media_player.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/vizio/media_player.py b/homeassistant/components/vizio/media_player.py index 68374ed59b9..5da96297736 100644 --- a/homeassistant/components/vizio/media_player.py +++ b/homeassistant/components/vizio/media_player.py @@ -223,13 +223,19 @@ class VizioDevice(MediaPlayerDevice): def volume_up(self): """Increasing volume of the device.""" - self._volume_level += self._volume_step / self._max_volume self._device.vol_up(num=self._volume_step) + if self._volume_level is not None: + self._volume_level = min(1., + self._volume_level + + self._volume_step / self._max_volume) def volume_down(self): """Decreasing volume of the device.""" - self._volume_level -= self._volume_step / self._max_volume self._device.vol_down(num=self._volume_step) + if self._volume_level is not None: + self._volume_level = max(0., + self._volume_level - + self._volume_step / self._max_volume) def validate_setup(self): """Validate if host is available and auth token is correct."""