BeoLink (Bang & Olufsen)

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?

it appeared to do the trick for me, what error do you get?

There’s a new warning error come in the more recent releases relating to some changes in the media player core component that at the moment doesn’t cause the component to break.

I’m going to have a try and fixing that at some point before it totally breaks the custom component

This is what I see:

Hi,
Did you comment out the import at the top?

import asyncio
#from asyncio.futures import CancelledError
import logging

Essentially what this is doing is importing the entire asyncio library rather than just the cancellederror as it’s no longer part of the futures package and has moved up the tree.
I think you could probably write it as from asyncio import CancelledError if you were worried about loading unnecessary code but I haven’t tested that.

I’ve also updated my copy with the MediaPlayerEntity to replace MediaPlayerDevice which is being deprecated, it was a very quick find and replace in two places so worth doing to get rid of the warning level error log message

Thanks @dano1 - I have now comments out “#from asyncio.futures import CancelledError” and also replaced MediaPlayerDevice with Entity - seems to be working again :slight_smile:

Hey there,

I started working on a new version on @marton ’ s BeoPlay integration which should support ZeroConf and actually be an official Home Assistant component in the future. Code in progress here: let me know what you think. @marton: I do need a few changes on your ha-beoplay library to enable zeroconf, it would be great if you could take the pull requests :slight_smile:

Awesome!! Looking forward to that! Thanks :pray::pray:

Thanks for the PRs @g.iac! I’ve merged them and updated the PyPi package.

1 Like

Hi,

I have been looking for a smart home system that can interact with B&O products since their own system (Beoliving) is only limited to a few other manufactors. This work seems to be the only one available, and it seems very promising. Since I am new to Home Assistant, I have difficulties to get this to work. When I copy the GitHub repository to “\config\custom_components\beoplay” I can in the Home Assistant gui go to “Configuration/Integrations” add the beoplay component.

First question: Do I need to add this for every device? I can see I have the possibility to chose between speaker and TV.

Second question: In the configuration.yaml file I have added:

# B&O
beoplay:
    host: 192.168.1.132

However, I get the following error:

* Invalid config for [beoplay]: [host] is an invalid option for [beoplay]. Check: beoplay->beoplay->host. (See /config/configuration.yaml, line 14).
* Component error: host - Integration 'host' not found.
* Invalid config for [media_player.beoplay]: [host] is an invalid option for [media_player.beoplay]. Check: media_player.beoplay->host. (See ?, line ?).
* Invalid config for [beoplay]: [host] is an invalid option for [beoplay]. Check: beoplay->beoplay->host. (See /config/configuration.yaml, line 15).

Can you tell me what I am doing wrong?

Best Regards,
Mads

You must type it like this:

media_player:
  - platform: beoplay
    host: 192.168.192.50
    name: Beoplay A9 Stuen

Thanks,

Now I have added two products in the configuration.yaml.

media_player:
  - platform: beoplay
    host: 192.168.192.109
    name: Beoplay Bad Oppe

  - platform: beoplay
    host: 192.168.192.128
    name: BeoVision 14

When I then try to restart the server, i get the following error:

Invalid config for [media_player.beoplay]: [host] is an invalid option for [media_player.beoplay]. Check: media_player.beoplay->host. (See ?, line ?). Invalid config for [media_player.beoplay]: [host] is an invalid option for [media_player.beoplay]. Check: media_player.beoplay->host. (See ?, line ?).

What does that mean?

Thanks for the help so far :slight_smile:

Did you install Martons integration or the one @g.iac posted recently?

At least martons integration should work with the config posted above.
Remember to comment out the

from asyncio.futures import CancelledError

in custom_components/beoplay/media_player.py, so that it looks like this:

#from asyncio.futures import CancelledError

I used the new integration by @g.iac but I have now changed to the one by Martons. I have changed the media_player.py to

#from asyncio.futures import CancelledError

and I still have the following in my configuration.yaml:

media_player:
  - platform: beoplay
    host: 192.168.192.109
    name: Beoplay Bad Oppe

  - platform: beoplay
    host: 192.168.192.128
    name: BeoVision 14

However, in my “Overview” tab, the status of my BeoVision is “Unknown” even though the tv is turned on. Any ideas on what I am doing wrong?