This commit is contained in:
2026-08-07 10:09:42 +02:00
parent 52d11bfff0
commit 52442c50f1
15 changed files with 827 additions and 252 deletions

View File

@@ -35,6 +35,8 @@ async def async_setup(hass, config):
async def async_set_half_service(service):
entity_ids = await async_extract_entity_ids(hass, service, expand_group=True)
for entity_id in entity_ids:
if not entity_id.startswith(f"{COVER_DOMAIN}."):
continue
data = {
ATTR_ENTITY_ID: entity_id,
ATTR_POSITION: hass.states.get(entity_id).attributes.get(ATTR_HALF_POSITION, 20)

View File

@@ -9,14 +9,8 @@ from ..reconnecting_client import ReconnectingClient
from .radio import find_local_radio_url_by_name, fill_station_cache_async
from homeassistant.components.media_player import (
MediaPlayerEntity, PLATFORM_SCHEMA)
from homeassistant.components.media_player.const import (
ATTR_MEDIA_ENQUEUE, DOMAIN, MEDIA_TYPE_MUSIC,
SUPPORT_CLEAR_PLAYLIST, SUPPORT_NEXT_TRACK, SUPPORT_PAUSE,
SUPPORT_PLAY, SUPPORT_PLAY_MEDIA, SUPPORT_PREVIOUS_TRACK, SUPPORT_SEEK,
SUPPORT_SHUFFLE_SET, SUPPORT_REPEAT_SET, SUPPORT_TURN_OFF, SUPPORT_TURN_ON,
SUPPORT_VOLUME_MUTE, SUPPORT_VOLUME_SET, REPEAT_MODE_ALL, REPEAT_MODE_OFF,
REPEAT_MODE_ONE,)
MediaPlayerEntity, PLATFORM_SCHEMA, MediaType, RepeatMode, ATTR_MEDIA_ENQUEUE)
from homeassistant.components.media_player.const import DOMAIN
from homeassistant.const import (
ATTR_COMMAND, CONF_HOST, CONF_PASSWORD, CONF_PORT, CONF_USERNAME, ATTR_ENTITY_ID,
STATE_IDLE, STATE_OFF, STATE_PAUSED, STATE_PLAYING)
@@ -28,10 +22,6 @@ _LOGGER = logging.getLogger(__name__)
DEFAULT_PORT = 9090
SUPPORT_SQUEEZEBOX = SUPPORT_PAUSE | SUPPORT_VOLUME_SET | \
SUPPORT_VOLUME_MUTE | SUPPORT_PREVIOUS_TRACK | SUPPORT_NEXT_TRACK | \
SUPPORT_SEEK | SUPPORT_TURN_ON | SUPPORT_TURN_OFF | SUPPORT_PLAY_MEDIA | \
SUPPORT_PLAY | SUPPORT_SHUFFLE_SET | SUPPORT_CLEAR_PLAYLIST | SUPPORT_REPEAT_SET
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
vol.Required(CONF_HOST): cv.string,
@@ -255,6 +245,23 @@ class LogitechMediaServer(ReconnectingClient):
class SqueezeBoxDevice(MediaPlayerEntity):
"""Representation of a SqueezeBox device."""
_attr_supported_features = (
MediaPlayerEntityFeature.PAUSE
| MediaPlayerEntityFeature.VOLUME_SET
| MediaPlayerEntityFeature.VOLUME_MUTE
| MediaPlayerEntityFeature.PREVIOUS_TRACK
| MediaPlayerEntityFeature.NEXT_TRACK
| MediaPlayerEntityFeature.SEEK
| MediaPlayerEntityFeature.TURN_ON
| MediaPlayerEntityFeature.TURN_OFF
| MediaPlayerEntityFeature.PLAY_MEDIA
| MediaPlayerEntityFeature.PLAY
| MediaPlayerEntityFeature.REPEAT_SET
| MediaPlayerEntityFeature.SHUFFLE_SET
| MediaPlayerEntityFeature.CLEAR_PLAYLIST
| MediaPlayerEntityFeature.STOP
)
def __init__(self, lms, playerid, name, **attributes):
"""Initialize the SqueezeBox device."""
super(SqueezeBoxDevice, self).__init__()
@@ -362,7 +369,7 @@ class SqueezeBoxDevice(MediaPlayerEntity):
@property
def media_content_type(self):
"""Content type of current playing media."""
return MEDIA_TYPE_MUSIC
return MediaType.MUSIC
@property
def media_duration(self):
@@ -446,11 +453,11 @@ class SqueezeBoxDevice(MediaPlayerEntity):
def repeat(self):
repeat_status = self._status.get('playlist repeat', 0)
if repeat_status == 1:
return REPEAT_MODE_ONE
return RepeatMode.ONE
elif repeat_status == 2:
return REPEAT_MODE_ALL
return RepeatMode.ALL
else:
return REPEAT_MODE_OFF
return RepeatMode.OFF
def set_repeat(self, repeat: str) -> None:
"""Set repeat mode."""