KNX - Media Player Control 🎶

It also reads following:

Choose at step 1: choice 10: Error executing script. Error for call_service at pos 1: Error rendering data template: TypeError: ‘NoneType’ object is not subscriptable

@torbenledermann
Is this expected?

So, according to my analysis the issue is related to the artist (and album + title) not being mapped to a group address. Since there’s the character limit of 14, I didn’t bother mapping it and / or there’s no need for me to ‘spam’ the bus with this information. Unfortunately, the blueprint doesn’t check whether the variable for the GA exists and is non-empty prior to accessing it.

That’s strange normally you should be able to simply leave out group adresses if you don’t use this information. Unfortunately recently i didn’t have that much time to take a look into the blueprint.
But I’ll try to take a look into that issue and some proposed feature requests

Thanks for Your feedback, @torbenledermann.

To short-cut things a bit I decided to create group addresses and map those from the blueprint. Unfortunately the error still occurs. Since we’re having radio stations on our favorites I believe it could still be related, i.e. empty album causes the error.

Error is still „NoneType“ or more precisely:

„Fehler: Error rendering data template: TypeError: ‘NoneType’ object is not subscriptable“

And that’s what tracer shows:

Okay that makes sense. Your media player doesn’t have a artist value in this case. That should be an easy fix. Thank you for your feedback

Yes, I checked that too for that very error.

It seems that a radio stream, may have / miss any combination of artist, title and album might. That’s evident from the media player’s state in Developer Tools.

Hm that’s strange I can’t edit my first post. Anyways I just released a new version.

V1.2.0 - Turn On/Off Action now usable, Shifting to next track when mediaplayer is already playing, Bugfixes regarding missing attributes.

The following features/bugfixes are included:

Is added now as a seperate pair of group addresses.

You can enable this sort of behaviour with a checkbox, next to setting up the group addresses for play/paus

This bug should be fixed now

Thanks, well appreciated, Torben!

I will test the update specifically against the error I‘ve been seeing in a couple of days and then share the results.

Have you already had time to implement the switching of the scenes/sources via ON/OFF telegram (DPT1)?

It would be really great if that worked.

Hi Torben,

I tried your blueprint with my squeezebox players but scene selection does not seem to work because “select_source” is not supported. Not sure if this is the best sollution, but I fixed it this way in case you like to extend your blueprint:

    sequence:
    - if:
      - condition: template
        value_template: "{{not is_squeezebox}}"
      then:
        - action: media_player.select_source
          target:
            entity_id: '{{ mediaplayer_entity }}'
          data:
            source: "{% set a = knx_scene_numbers %}\n{% set b = trigger.payload %}\n{%
              set result = namespace(value=false) %}\n{% set counter = namespace(value=0)
              %}\n{% for item in a %}\n  {% if (b[0]+1) == item %} {% set result.value
              = counter.value %} {% else %} {% set counter.value = counter.value +1 %}
              {% endif %}\n{% endfor %}\n{{scene_number_actions[result.value]}}"
      else:
        - action: squeezebox.call_method
          target:
            entity_id: '{{ mediaplayer_entity }}'
          data:
            command: favorites
            parameters: "{% set a = knx_scene_numbers %}\n{% set b = trigger.payload %}\n{%
              set result = namespace(value=false) %}\n{% set counter = namespace(value=0)
              %}\n{% for item in a %}\n  {% if (b[0]+1) == item %} {% set result.value
              = counter.value %} {% else %} {% set counter.value = counter.value +1 %}
              {% endif %}\n{% endfor %}\n{{['playlist', 'play', 'item_id:' + scene_number_actions[result.value]|string]}}"

Hi there,
I wanted to know if it is possible to get the Name of the Favorites. I would like to see this as text on my MDT Glastaster.

Thanks!

If you had problems with the relative volume control. Check out the latest version, which I just published

V1.2.1 - Bugfix: Relative volume control didn’t work properly

Decided to quickly add this functionality. For every Scene you can now define a 1 Bit group address. ‘1’ send to this address starts the scene, a ‘0’ pauses the music.

V1.3.0 - NEW: 1 bit group adresses can be defined for each scene
V1.3.1 - Bugfix: Scene 8 was missing

You mean the individual name that you define within the blueprint? So when you start a Scene, the name of the scene should be sent to a group address? At the moment, you can get the title and the artist.

Hi @torbenledermann and thanks for this Blueprint!

When using a radio source (at least with my Yamaha receiver) the receiver sets the state to “idle” when “ON” and “off” when “Off”. O think by using the “off” value instead of “playing” for the on/off state will be more robust and also work in other cases as well.

Here is my patch (see revision 10):

1 Like

Version: 1.4.0

  • [New Feature] - You can now specify a dedicated text message for artist, album and title, when the music is paused or the media player is turned off. Thanks to s-anderss
  • [New Feature] - The text messages will now also get updated, when the media player is started/paused not only via KNX
  • [Bugfix] - Implemented the fix regarding the on/off state provided by @remuslazar
  • [Bugfix] - You can now specify the media player type for the scene control to be compatible with squeezbox and music assistant. Thanks to s-anderss

Version: 1.4.1

[New Feature] - Dedicated text messages for the buffering state
[New Feature] - Option to send media_stop command instead of media_pause
[Bugfix] - Media player type for “Denon Home” added

Version: 1.4.2
[Bugfix] - Rewritten the logic for calling scenes via the 1 Bit group addresses. They now also consider the chosen media player type.

Hi,

I recently tested the Blueprint, and it worked seamlessly. Now, I can control a media player with a single button on my Gira Tastsensor, allowing me to play, stop, and adjust the volume. I particularly appreciate the ability to stop instead of pause, which is not available in the media player card UI. The pause option doesn’t make sense for radio stations from my perspective.

My main use case is to activate a local radio station in the bathroom using the KNX button and let the motion sensor turn it off later. So far, everything is working well.

However, I’m unsure how to set a default media source, such as my preferred radio station. Is there a way to configure a preset radio station or play the last source I listened to? Even in the UI, every time I open the media player card after a while, I have to reselect the radio station.

Does anyone have any suggestions?

Thank you for your support.