Fix MusicCast subwoofers (#52335)

This commit is contained in:
Tom Schneider 2021-06-30 13:09:57 +02:00 committed by GitHub
parent a7ece4ecaa
commit dc407fe7a1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 23 additions and 20 deletions

View File

@ -4,7 +4,7 @@
"config_flow": true, "config_flow": true,
"documentation": "https://www.home-assistant.io/integrations/yamaha_musiccast", "documentation": "https://www.home-assistant.io/integrations/yamaha_musiccast",
"requirements": [ "requirements": [
"aiomusiccast==0.6" "aiomusiccast==0.8.0"
], ],
"ssdp": [ "ssdp": [
{ {

View File

@ -4,12 +4,12 @@ from __future__ import annotations
import logging import logging
from aiomusiccast import MusicCastGroupException from aiomusiccast import MusicCastGroupException
from aiomusiccast.features import ZoneFeature
import voluptuous as vol import voluptuous as vol
from homeassistant.components.media_player import PLATFORM_SCHEMA, MediaPlayerEntity from homeassistant.components.media_player import PLATFORM_SCHEMA, MediaPlayerEntity
from homeassistant.components.media_player.const import ( from homeassistant.components.media_player.const import (
REPEAT_MODE_OFF, REPEAT_MODE_OFF,
SUPPORT_CLEAR_PLAYLIST,
SUPPORT_GROUPING, SUPPORT_GROUPING,
SUPPORT_NEXT_TRACK, SUPPORT_NEXT_TRACK,
SUPPORT_PAUSE, SUPPORT_PAUSE,
@ -55,13 +55,8 @@ from .const import (
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
MUSIC_PLAYER_SUPPORT = ( MUSIC_PLAYER_BASE_SUPPORT = (
SUPPORT_PAUSE SUPPORT_PAUSE
| SUPPORT_VOLUME_SET
| SUPPORT_VOLUME_MUTE
| SUPPORT_TURN_ON
| SUPPORT_TURN_OFF
| SUPPORT_CLEAR_PLAYLIST
| SUPPORT_PLAY | SUPPORT_PLAY
| SUPPORT_SHUFFLE_SET | SUPPORT_SHUFFLE_SET
| SUPPORT_REPEAT_SET | SUPPORT_REPEAT_SET
@ -210,13 +205,17 @@ class MusicCastMediaPlayer(MusicCastDeviceEntity, MediaPlayerEntity):
@property @property
def volume_level(self): def volume_level(self):
"""Return the volume level of the media player (0..1).""" """Return the volume level of the media player (0..1)."""
if ZoneFeature.VOLUME in self.coordinator.data.zones[self._zone_id].features:
volume = self.coordinator.data.zones[self._zone_id].current_volume volume = self.coordinator.data.zones[self._zone_id].current_volume
return (volume - self._volume_min) / (self._volume_max - self._volume_min) return (volume - self._volume_min) / (self._volume_max - self._volume_min)
return None
@property @property
def is_volume_muted(self): def is_volume_muted(self):
"""Return boolean if volume is currently muted.""" """Return boolean if volume is currently muted."""
if ZoneFeature.VOLUME in self.coordinator.data.zones[self._zone_id].features:
return self.coordinator.data.zones[self._zone_id].mute return self.coordinator.data.zones[self._zone_id].mute
return None
@property @property
def shuffle(self): def shuffle(self):
@ -350,7 +349,17 @@ class MusicCastMediaPlayer(MusicCastDeviceEntity, MediaPlayerEntity):
@property @property
def supported_features(self): def supported_features(self):
"""Flag media player features that are supported.""" """Flag media player features that are supported."""
return MUSIC_PLAYER_SUPPORT supported_features = MUSIC_PLAYER_BASE_SUPPORT
zone = self.coordinator.data.zones[self._zone_id]
if ZoneFeature.POWER in zone.features:
supported_features |= SUPPORT_TURN_ON | SUPPORT_TURN_OFF
if ZoneFeature.VOLUME in zone.features:
supported_features |= SUPPORT_VOLUME_SET
if ZoneFeature.MUTE in zone.features:
supported_features |= SUPPORT_VOLUME_MUTE
return supported_features
async def async_media_previous_track(self): async def async_media_previous_track(self):
"""Send previous track command.""" """Send previous track command."""
@ -374,12 +383,6 @@ class MusicCastMediaPlayer(MusicCastDeviceEntity, MediaPlayerEntity):
"Service next track is not supported for non NetUSB or Tuner sources." "Service next track is not supported for non NetUSB or Tuner sources."
) )
def clear_playlist(self):
"""Clear players playlist."""
self._cur_track = 0
self._player_state = STATE_OFF
self.async_write_ha_state()
async def async_set_repeat(self, repeat): async def async_set_repeat(self, repeat):
"""Enable/disable repeat mode.""" """Enable/disable repeat mode."""
if self._is_netusb: if self._is_netusb:

View File

@ -209,7 +209,7 @@ aiolyric==1.0.7
aiomodernforms==0.1.8 aiomodernforms==0.1.8
# homeassistant.components.yamaha_musiccast # homeassistant.components.yamaha_musiccast
aiomusiccast==0.6 aiomusiccast==0.8.0
# homeassistant.components.keyboard_remote # homeassistant.components.keyboard_remote
aionotify==0.2.0 aionotify==0.2.0

View File

@ -134,7 +134,7 @@ aiolyric==1.0.7
aiomodernforms==0.1.8 aiomodernforms==0.1.8
# homeassistant.components.yamaha_musiccast # homeassistant.components.yamaha_musiccast
aiomusiccast==0.6 aiomusiccast==0.8.0
# homeassistant.components.notion # homeassistant.components.notion
aionotion==1.1.0 aionotion==1.1.0