mirror of
https://github.com/home-assistant/core.git
synced 2025-07-28 23:57:06 +00:00
Fix MusicCast subwoofers (#52335)
This commit is contained in:
parent
a7ece4ecaa
commit
dc407fe7a1
@ -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": [
|
||||||
{
|
{
|
||||||
|
@ -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)."""
|
||||||
volume = self.coordinator.data.zones[self._zone_id].current_volume
|
if ZoneFeature.VOLUME in self.coordinator.data.zones[self._zone_id].features:
|
||||||
return (volume - self._volume_min) / (self._volume_max - self._volume_min)
|
volume = self.coordinator.data.zones[self._zone_id].current_volume
|
||||||
|
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."""
|
||||||
return self.coordinator.data.zones[self._zone_id].mute
|
if ZoneFeature.VOLUME in self.coordinator.data.zones[self._zone_id].features:
|
||||||
|
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:
|
||||||
|
@ -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
|
||||||
|
@ -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
|
||||||
|
Loading…
x
Reference in New Issue
Block a user