If volume disabled do not enable support (#28635)

This commit is contained in:
Barry Williams 2019-11-26 06:34:45 +00:00 committed by Paulus Schoutsen
parent 1f72de108c
commit afaa464142
3 changed files with 10 additions and 14 deletions

View file

@ -17,14 +17,7 @@ from homeassistant.components.media_player.const import (
)
from homeassistant.const import STATE_IDLE, STATE_OFF, STATE_PAUSED, STATE_PLAYING
SUPPORT_OPENHOME = (
SUPPORT_SELECT_SOURCE
| SUPPORT_VOLUME_STEP
| SUPPORT_VOLUME_MUTE
| SUPPORT_VOLUME_SET
| SUPPORT_TURN_OFF
| SUPPORT_TURN_ON
)
SUPPORT_OPENHOME = SUPPORT_SELECT_SOURCE | SUPPORT_TURN_OFF | SUPPORT_TURN_ON
_LOGGER = logging.getLogger(__name__)
@ -79,14 +72,19 @@ class OpenhomeDevice(MediaPlayerDevice):
self._in_standby = self._device.IsInStandby()
self._transport_state = self._device.TransportState()
self._track_information = self._device.TrackInfo()
self._volume_level = self._device.VolumeLevel()
self._volume_muted = self._device.IsMuted()
self._source = self._device.Source()
self._name = self._device.Room().decode("utf-8")
self._supported_features = SUPPORT_OPENHOME
source_index = {}
source_names = list()
if self._device.VolumeEnabled():
self._supported_features |= (
SUPPORT_VOLUME_STEP | SUPPORT_VOLUME_MUTE | SUPPORT_VOLUME_SET
)
self._volume_level = self._device.VolumeLevel()
self._volume_muted = self._device.IsMuted()
for source in self._device.Sources():
source_names.append(source["name"])
source_index[source["name"]] = source["index"]