Logitech Squeezebox - examples of how to use the API in HA

When i search for “www.abc.net.au podcast xml latest news” i get a few options.
Is this wat you are looking for?

https://www.abc.net.au/feeds/101858056/podcast.xml

btw if i’ts not a ‘real’ podcast that you can download an listen offline there isn’t an api and verry difficult to get a usable link.

1 Like

Yes… I think I have found the link there. Thanks for that.

Did you fixt this?

I was trying to do the same, but now i get the next error in my logs:
Error while executing automation automation.radio_zenders: not a valid value for dictionary value @ data[‘entity_id’]

Offcourse i changed my sensor name in to the “input_select” name that i’m using


entity_id: media_player.{{ states('input_select.chromecast_radio_station') }}

Thanks for the quick reply Kabala.
It’s working now, don’t know why it wasn’t working with the “entity_id”. Probaly to tired yesterday.
But one thing i do know, it isn’t working over here with the “item_id” number.
I do see the “id” numbers, but they would not work. I have to use the name of the playlist it self and then its working.

Working:

{% if is_state('input_select.radio_zenders', 'Veronica') %} 
 ["play", "Radio Veronica"] 

Not working:

{% if is_state('input_select.radio_zenders', 'Veronica') %}
["playlist", "play", "item_id:43"]

Also did try to change “item_id” with “id” and also did between " "

And if i send the “service call Query” i do get this:

query_result:
  playlists_loop:
    - playlist: Radio Veronica
      id: 43

this is my script for the radio stations in lms as a favorite

service: squeezebox.call_method
target:
  entity_id: media_player.{{states.input_select.lms_player.state}}
data:
  command: favorites
  parameters: >
    {% if is_state('input_select.chromecast_radio_station', 'ProFM') %}
      ["playlist", "play", "item_id:0"]
    {% elif is_state('input_select.chromecast_radio_station', 'KissFM') %}
      ["playlist", "play", "item_id:1"]
    {% elif is_state('input_select.chromecast_radio_station', 'EuropaFM') %}
      ["playlist", "play", "item_id:2"]
    {% elif is_state('input_select.chromecast_radio_station', 'RadioZu') %}
      ["playlist", "play", "item_id:3"]
    {% elif is_state('input_select.chromecast_radio_station', 'DigiFM') %}
      ["playlist", "play", "item_id:4"]
    {% elif is_state('input_select.chromecast_radio_station', 'MagicFM') %}
      ["playlist", "play", "item_id:5"]
    {% elif is_state('input_select.chromecast_radio_station', 'VirginRadio') %}
      ["playlist", "play", "item_id:6"]
    {% elif is_state('input_select.chromecast_radio_station', 'RadioPetrecere')
    %}
      ["playlist", "play", "item_id:7"]
    {% elif is_state('input_select.chromecast_radio_station', 'NationalFM') %}
      ["playlist", "play", "item_id:8"]
    {% elif is_state('input_select.chromecast_radio_station', 'WefunkRadio') %}
      ["playlist", "play", "item_id:9"]
    {% elif is_state('input_select.chromecast_radio_station', 'FunkyRadio') %}
      ["playlist", "play", "item_id:10"]
    {% elif is_state('input_select.chromecast_radio_station',
    'RadioFunkyThrills') %}
      ["playlist", "play", "item_id:11"]
    {% elif is_state('input_select.chromecast_radio_station', 'Bayern1') %}
      ["playlist", "play", "item_id:12"]
    {% elif is_state('input_select.chromecast_radio_station', 'Bayern3') %}
      ["playlist", "play", "item_id:13"]
    {% elif is_state('input_select.chromecast_radio_station', 'Charivari') %}
      ["playlist", "play", "item_id:14"]
    {% elif is_state('input_select.chromecast_radio_station', 'Energy') %}
      ["playlist", "play", "item_id:15"]
    {% elif is_state('input_select.chromecast_radio_station', 'AntenneBayern')
    %}
      ["playlist", "play", "item_id:16"]
    {% elif is_state('input_select.chromecast_radio_station', 'RadioMedias') %}
      ["playlist", "play", "item_id:17"]
    {% endif %}

That is not working here, this is mine. Only i did put mine in a automation:

alias: Radio Zenders
description: ""
trigger:
  - platform: state
    entity_id:
      - input_select.radio_zenders
  - platform: state
    entity_id:
      - input_select.speaker
condition: []
action:
  - service: squeezebox.call_method
    data_template:
      entity_id: media_player.{{ states('input_select.speaker') }}
      command: playlist
      parameters: |
        {% if is_state('input_select.radio_zenders', 'Veronica') %}
          ["play", "Radio Veronica"]
        {% elif is_state('input_select.radio_zenders', 'Veronica Rock') %}
          ["play", "Veronica Rock Hits Top 500"]
        {% elif is_state('input_select.radio_zenders', 'SLAM!') %}
          ["play", "SLAM!"]
        {% elif is_state('input_select.radio_zenders', 'Radio 538') %}
          ["play", "Radio 538"]
        {% elif is_state('input_select.radio_zenders', 'KINK') %}
          ["play", "KINK"]
        {% elif is_state('input_select.radio_zenders', '3FM') %}
          ["play", "3FM"]
        {% elif is_state('input_select.radio_zenders', 'Omrop Fryslân') %}
          ["play", "Omrop Fryslan"]
        {% endif %}
mode: single

Hi Anwen,
Is this still working at your end?
I used your code but with some other artist and album. The current playlist gets reset but nothing new added.
Is the Genre required or can I just leave it away?

Thanks,

Merc

Edit: got the album adding working but strange enough the playlist play command does not start the music. It is basically sitting there with the new album and not starting to play. Any idea?

Edit 2: used a different method and finalised it to what I actually wanted to do.
With this automation you can ask voice assistant to play an album by a specific artist on a specific music player.

alias: "Assist: Play music on Squeezebox"
description: Play music on Squeezebox
trigger:
  - platform: conversation
    command:
      - Play {album} by {artist} in {player}
    enabled: true

action:
  - service: squeezebox.call_method
    data:
      command: playlist
      parameters:
        - addalbum
        - ""
        - "{{trigger.slots.artist}}"
        - "{{trigger.slots.album}}"
    target:
      entity_id: media_player.{{trigger.slots.player}}
  - service: media_player.media_play
    data: {}
    target:
      entity_id: media_player.{{trigger.slots.player}}
mode: single
2 Likes

I was just writing a reply when I saw your new edit. It does still work for me as I wrote it. Glad you got it to do what you wanted…thanks for sharing your solution!

Thanks anyway Anwen,
I don’t quite understand why your method does not do anything here but at least there is another way to do it.

I am quite surprised how well voice assistant does it’s job even on a pi.
It struggles a bit with band names and album titles but overall does a great job.

1 Like

If anybody can think of a way to search for just one song by an artist and play that , based on a voice command, that would be great.
So far I have not managed to rebuild the search functionality of the squeezeserver in Home Assistant.

Hi @Kabala, did you ever find out how to do this? I would like Home Assistant to notice when a Squeezebox Player is playing and then trigger the appropriate amplifier to switch on. I don’t know how to have HA monitor LMS for players’ playing/not-playing status.

Is there a reason you don’t just install the integration?

@ozpac I think I used the DLNA integration to allow the players to show up in HA as a media player. As soon as the player shows as playing it triggers the automation below to switch on the amp. Use Developer Tools to check the media_player.kitchen shows up and is working correctly. Works really well for me. I found the DLNA was the fastest response than alternative integrations. From memory in LMS you MIGHT need to install one of the bridges to allow the player to show in DLNA.

alias: Kitchen Amp Turn On
description: ""
trigger:
  - platform: state
    entity_id:
      - media_player.kitchen_2
    to: playing
condition: []
action:
  - service: switch.turn_on
    data: {}
    target:
      entity_id: switch.kitchen_amp_power
mode: single

edit: I run my LMS separately from HA as it works so well and my family after ten years has almost got comfortable with the lovely material interface!!! “Over my dead body” is anything going to change!

do you have any hint how can i ask HA to play something from apps in Logitech Media Server integration?

Hello,

I using LMS and squeezelite addons running on Raspberrypi 4 with homeassistant.

I have added my music folder to lms, the songs plays fine.

Please guide how to play a particular folder/album using automation.

Kindly reply

I would advise you to try some of the examples in this tread.

Thanks a lot for this example.

Can you you please guide me how to play a music folder ?

service: squeezebox.call_method
target:
  entity_id:
    - media_player.squeezelite_ha_addon_2_2
  device_id: []
  area_id: []
data:
  command: playlist
  parameters: 
     - musicfolder
     - Enigma

I tried this but it didnt work.

In order to help you, please read this.

You will need to know the full path to your given music folder item as seen by Logitech Media Server (LMS). This will derive from whatever you added to the basic settings as your media folder when you set LMS up:

service: squeezebox.call_method
target: 
  entity_id: media_player.<your_player_here>
data:
  command: playlist
  parameters:
    - add # Adds folder to end of playlist. Can also be 'play' (clears entire playlist), or 'insert' (inserts it as next item)
    - "/path/to/your/music/folder/Enigma"

To be extra sure, wrap your folder path in quotes if it contains spaces.

1 Like