BeoLink (Bang & Olufsen)

Hi!
Quick question - I have an Avant 55 TV and my sources response is like the cutout at the bottom (just the first few lines).

Shouldn’t the getSources code be something like this?

def getSources(self):
        r = self._getReq('BeoZone/Zone/Sources')
        if r:
            for elements in r["sources"]:
                i = 0
                while i < len(r["sources"]):
                    self.sources.append(r["sources"][i][1]["friendlyName"])
                    self.sourcesID.append(r["sources"][i][0])
                    i += 1

Granted I am not a python expert …

BTW, I think Home Assistant automatically installed the ha-beoplay on my Rasberry Pi, but I can’t find it in /config/deps… where do I find the file to test any changes?

Thanks for the help

{
   "sources":[
      [
         "homemedia:[email protected]",
         {
            "friendlyName":"HOMEMEDIA",
            "sourceType":{
               "type":"HOMEMEDIA"
            },
            "category":"MEDIA",
            "inUse":true,
            "signalSensed":true,
            "profile":"",
            "borrowed":false,

Hi,

It’s been a while since, I worked on this. But for me the sources show up correctly. Though I only have speakers and not a TV. There might be a difference.

When you set up the custom component, it has a dependency of that python library, so it automatically downloads it from pypi. I think you can adjust that so it refers to a local library, but I can’t remember how it’s done. I would suggest to look at the home assistant dev docs. I’ll try to look there as well.

Hi Marton, I think I found the issue. PyPl has an old version of your library. Home assistant on the raspberry pi automatically downloads the code at pypl to satisfy the REQUIREMENT in the manifest, and that version is old.

You made some edits after that, but PyPl did not pick it up. Can you change the version number to 0.0.6 so that The new version of the code makes its way through the system?

Great plugin.
I have a BS35, that works perfectly with this, but for some reason i don’t get radio station or info back to HA, when i select TuneIn as source. It is shown in display on the BS35, so it must be available.
Let me know if can help you pick up some info

thanks

Thanks @kimc. I am quite busy these days and don’t have time to look at this plugin, but I will at some point as I am using it as well :slight_smile:

@g.iac thank you, I’ve merged your pull request.

would it be possible to add the join/unjoin functionality as mentioned here: mini media player, to get the multiroom experience into the media player

Hi Marton, can you also please create a release and send it to pypi (this https://pypi.org/project/ha-beoplay/ still has the old code which does not work, and it gets installed automatically by home assistant when I install the beo plugin you wrote).

I believe the pypi has not been updated yet.
In case Marton is not available at the time, is there anything we can do to get the update pushed through?

Sorry guys, I’ve been quite busy. I’ll update pypi today.

1 Like

It should be updated, but please check it guys.

2 Likes

Running HA 0.113.1 i get this error after reboot:
ImportError: cannot import name ‘CancelledError’ from ‘asyncio.futures’ (/usr/local/lib/python3.8/asyncio/futures.py)

Just tried it as well. Same error for me. Running 0.113.0

I’m still on 0.107.7, running a bit behind, but I will update and test it.

I “fixed” that by removing that type of exception from the integration code, but not sure it is the best approach.

Hi Giovanni
When you say you removed the exception from the integration code - where about’s did you make the change?

I can see in media_player.py around line 180 there’s an exception:
except CancelledError:
_LOGGER.debug(“Stopping the polling of node %s”, self._name)

Did you remove this or is there something else?

Appreciate the help on this, and the work on this component, really improves how my speakers work with HA so much missed functionality

Dan

Yeah, I commented these two lines out. The exception is caught further down. The real solution is replacing the Cancelled Error with the new implementation, but I don’t know enough about python to do it.

Thanks for confirming. I’ve commented line 5 out too, but from what I can see that’s just a more specific import from the line above (my python knowledge is non existent so I’m basing this on very rusty university java!)

From digging through the source on github I found some other references to cancellation errors

import asyncio
from concurrent import futures
from functools import partial

– that futures.CancelledErrors can also occur in some situations.
CANCELLATION_ERRORS = (asyncio.CancelledError, futures.CancelledError)

Maybe this will be of more help to someone who understands the code better!

I’ve got the component running again now, I guess without this it may throw up the odd unhandled exception to the upper code but we’ll see

Thanks again

I think I may have found out why this issue has occurred and how to fix it.

According to the docs when asyncio went from version 3.7 to 3.8 CancelledError changed to be a subclass of BaseException:
https://docs.python.org/3/library/asyncio-exceptions.html#asyncio.CancelledError

I checked around for some other examples of apps impacted by this change at it appeared to be that referencing the exception type explicitly solves the problem

so on line 180 instead of:
except CancelledError:

replace this with:
except asyncio.CancelledError:

I need to do some testing to see if everything is still working as expected, but so far the error messages have gone away and the devices are still showing

2 Likes

did you guys that do this work see this homebridge integration?

I thought that might be of help.

Hi,
I have (less than) no programming skils but i tried to change line 180 at you wrote - it did not help for me - did it help you ? or did you got the issue solved in another way?