Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PLAY_MEDIA, GROUPING services not available #23

Open
NiMa08 opened this issue Jan 7, 2023 · 8 comments
Open

PLAY_MEDIA, GROUPING services not available #23

NiMa08 opened this issue Jan 7, 2023 · 8 comments

Comments

@NiMa08
Copy link

NiMa08 commented Jan 7, 2023

I'm trying to use the services PLAY_MEDIA and Grouping on my hifiberry speakers, but i see they are not added in the supported services. Also the speakers aren't visible in the media sources list. Is there a fix for this?

@willholdoway
Copy link
Owner

This would need help from @schnabel and his audiocontrol2, which is beyond my capability. I would suggest I implement as per the below:

`from homeassistant.components.media_player import MediaPlayerEntityFeature

class HifiberryMediaPlayer(MediaPlayerEntity):
"""Hifiberry Media Player Object."""

# Existing methods...

@property
def supported_features(self):
    """Flag media commands that are supported."""
    return (
        SUPPORT_HIFIBERRY |
        MediaPlayerEntityFeature.PLAY_MEDIA |  # Add support for PLAY_MEDIA
        MediaPlayerEntityFeature.GROUPING      # Add support for grouping if applicable
    )

async def async_play_media(self, media_type, media_id, **kwargs):
    """Play a media from a URL or a media source."""
    # Implementation depends on your device capabilities
    if media_type == 'url':
        await self._audiocontrol2.play_url(media_id)
    elif media_type == 'playlist':
        await self._audiocontrol2.play_playlist(media_id)
    else:
        _LOGGER.error("Unsupported media_type: %s", media_type)

# Example method to handle grouping (simplified version)
async def join_group(self, leader):
    """Join the speaker to another speaker group."""
    await self._audiocontrol2.join_group(leader)

async def leave_group(self):
    """Leave the speaker group."""
    await self._audiocontrol2.leave_group()

# Method to make the speakers visible in media sources
@property
def media_sources(self):
    """Return available media sources."""
    return [
        {'id': 'source_1', 'title': 'Playlist 1'},
        {'id': 'source_2', 'title': 'Playlist 2'}
    ]

`

@schnabel
Copy link
Contributor

@NiMa08 if you are still interested ... let me know. But I do not have a lot of time at the moment :-(.

@NiMa08
Copy link
Author

NiMa08 commented Apr 12, 2024

Haven’t looked at this for a while. So have to refresh myself. But yes still very interested!

@NiMa08
Copy link
Author

NiMa08 commented Apr 21, 2024

is there anything i can help with? I'm new to developing home assistant integrations, but i have some time now. Just need some nudges the right direction if there is something i can do.

@schnabel
Copy link
Contributor

I am not sure if I got all the requirements from @willholdoway code snippet right. I seen 4 new methods, but I am sure about the expectations.

  • what needs to be done on join and leave group? Is audiocontrol2 supposed to address multiple hifiberries?
  • playing urls and playlist is unclear to me because the hifiberry supports many different players (mpd, spotify, bluetooth etc.) and I think it is not easy to address them all with media_ids of tracks or playlists.

Unfortunately I have a side project that eats 150% of my time at the moment. @NiMa08 if you can clarify the requirements or if have questions or code contributions for https://github.com/schnabel/pyhifiberry ... let me know.

@NiMa08
Copy link
Author

NiMa08 commented Apr 27, 2024

Hmm are you able to help with any of this @willholdoway? I'm not sure where to start. @schnabel & @willholdoway Can we chat on discord?: nima008.

@willholdoway
Copy link
Owner

willholdoway commented Apr 29, 2024 via email

@schnabel
Copy link
Contributor

Hi @NiMa08. I am not on discord, sorry. It might be a good starting point to have a look at the sonos integration to understand the requirements. If you or @willholdoway can answer the questions from above, I will try to find out if there is a way to address it in audiocontrol2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants