Error accessing mopidy core api

Hi guys!

I try to get started developing an own frontend to learn how extension development for mopidy is working.
My frontend tries to access mopidy core api as described in the documentation. Anyway I get errors and I tried to find out what is causing that error but for hours I didn’t reach any progress. Does somebody has an advice form me what I’m doing wrong?

Here ist he (really simple) code of my frontend class:

    import pykka
    import logging
    import gpiozero as GPIO
    from mopidy import core

    logger = logging.getLogger(__name__)

    class StephansMusicboxFrontend (pykka.ThreadingActor, core.CoreListener):
        def __init__(self, config, core):
            super(StephansMusicboxFrontend, self).__init__()
            self.core = core
            self.config = config

        def _getCurrentVolume(self):
  "try to get volume")
            currentVolume =  self.core.MixerController.get_volume()

I’m trying to get the current volume from mopidy and print this out in console. But this raises an error.
Can anybody give me please an advice? Many thanks!

Here is the error code:

ERROR    2020-03-12 11:30:54,644 [3532:MainThread] mopidy.commands
  Got un-handled exception from StephansMusicboxFrontend
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/mopidy/", line 240, in _actor_error_handling
  File "/usr/lib/python3/dist-packages/mopidy/", line 436, in start_frontends
    frontend_class.start(config=config, core=core)
  File "/usr/lib/python3/dist-packages/pykka/", line 91, in start
    obj = cls(*args, **kwargs)
  File "/usr/local/lib/python3.7/dist-packages/magister85-0.0.1-py3.7.egg/mopidy_stephans_musicbox/", line 15, in __init__
  File "/usr/local/lib/python3.7/dist-packages/magister85-0.0.1-py3.7.egg/mopidy_stephans_musicbox/", line 19, in _getCurrentVolume
    currentVolume =  self.core.MixerController.get_volume()
  File "/usr/lib/python3/dist-packages/pykka/", line 219, in __getattr__
    raise AttributeError('{} has no attribute {!r}'.format(self, name))
AttributeError: <ActorProxy for Core (urn:uuid:c05a7c52-fb4b-4233-85b6-9994c0f80d1c), attr_path=()> has no attribute 'MixerController'


MixerController is only the name of the class. The instance of MixerController is available as self.core.mixer.

self.core.mixer.get_volume() returns a future, so you’ll need to call .get() on that to get the integer value out of the future object.


currentVolume = self.core.mixer.get_volume().get()

Thank you Jodal! Made my day! Where I have to send the box of cocolates? :wink: I will study the pykka documentation more intensive. That was the hint I needed.

1 Like