Frontier Silicon device: change radio station in internet radio mode by use of presets

Hi,
I’m new to Home Assistant and started a few days ago. I have integrated some Frontier Silicon devices (Medion, Silvercrest) to the UI as media_player and all works well.
Now I’m searching for a possibility to choose different radio stations from the UI, which I stored to my devices as presets. After looking at the help pages for Frontier Silicon and Media Player it seems that this feature is not supported. Searching the forum for this topic I found this conversation, in which using shell commands is suggested.
As this topic is about 2 years old, I’d like to ask whether there is already an integration of presets (which I missed to find) or whether it is planned for the near future.

After inspiration through several posts in the forum, I found the following solution for me.
in configuration.yaml I setup my internet radio:

media_player:
  - platform: frontier_silicon
    host: 192.168.178.77
    name: Homeoffice

then added the following rest commands in configuration.yaml, too:

rest_command:
  fs_nav_state_on:
    url: "http://{{ ip }}/fsapi/SET/netremote.nav.state?pin=1234&value=1"
  fs_nav_state_off:
    url: "http://{{ ip }}/fsapi/SET/netremote.nav.state?pin=1234&value=0"
  fs_select_preset:
    url: "http://{{ ip }}/fsapi/SET/netRemote.nav.action.selectPreset?pin=1234&value={{ preset_no }}"

As next step I created an input_select via the GUI. The first entry is ‘None’ and the following entries are holding the names of my favourite internet stations in the same order as entered as preset in my device (via UNDOK). As name I typed “fs_presets_selector_homeoffice” and got Entity-ID “input_select.fs_presets_selector_homeoffice”. The input_select has to be added to the lovelace-window, then.

Then I added the following in scripts.yaml:

fs_select_preset_homeoffice:
  alias: fs_select_preset_homeoffice
  sequence:
  - service: media_player.turn_on
    data:
      entity_id: media_player.homeoffice
  - service: media_player.select_source
    data:
      entity_id: media_player.homeoffice
      source: "Internet radio"
  - service: rest_command.fs_nav_state_on
    data:
      ip: "192.168.178.77:80"
  - service: rest_command.fs_select_preset
    data_template:
      ip: "192.168.178.77:80"
      preset_no: >
        {% if is_state("input_select.fs_presets_selector_homeoffice", "ANTENNE BAYERN") %} 0
        {% elif is_state("input_select.fs_presets_selector_homeoffice", "Regenbogen Zwei") %} 1
        {% elif is_state("input_select.fs_presets_selector_homeoffice", "BAYERN 1 Mainfranken") %} 2
        {% endif %}
  - service: rest_command.fs_nav_state_off
    data:
      ip: "192.168.178.77:80"

This script turns on the radio, sets it into navigation mode, sends the number of the station (0, 1, 2) which was selected and finally turns navigation mode off.

The last step was creating two automations. First I tried it via GUI and then edited it in automations.yaml as follows:

- id: '1609346860154'
  alias: Auto_select_Preset_Homeoffice
  description: ''
  trigger:
  - platform: state
    entity_id: input_select.fs_presets_selector_homeoffice
  condition:
    condition: not
    conditions:
      - condition: state
        entity_id: input_select.fs_presets_selector_homeoffice
        state: 'None'
  action:
  - service: script.fs_select_preset_homeoffice
    data: {}
  mode: single
- id: '1609428102356'
  alias: 'Auto_select_Preset_Homeoffice_None'
  description: ''
  trigger:
  - platform: state
    entity_id: input_select.fs_presets_selector_homeoffice
    to: "None"
  condition: []
  action:
  - service: media_player.turn_off
    data:
      entity_id: media_player.homeoffice
  mode: single

The first automation will be executed when a radio station is selected in input_select and then will switch to the choosen station. The second one turns off the radio, when ‘None’ is selected.

Hope it will help someone.
It would be nice to fill the input_select ‘automatically’ with the presets from the device. But this is beyond my capability at the moment.

6 Likes

@Heinz I just want to say a huge thank you for this. Very easy to follow and works perfectly. Did you ever figure out how to automatically pull presets from Undok? Thanks again for all your efforts on this and sharing with the wider community, you’ve saved me hours of work.

@Cergon Glad to be of assistance! Regarding pulling presets I unfortunatelly didn’t succeed.

You may want to take a look at this PR: Switch channels via media browser and play_media service by buzz-tee · Pull Request #58960 · home-assistant/core · GitHub

I’m showing the presets as “Channels” in the media library (also includes support for selectPreset via the media_player.play_media service).

EDIT: had to re-work my PR

I purchased and succesfully coneccted Auna 320BT tuner to HA via frontier silicon integration and a number of rest commands, so i can confirm that it works.
I can turn on/off, set volume, mute, switch DAB+ preset stations via rest commands…

But, what i wonder is this: is it possible to have a reversed information of preset status? I mean - is it possible to create a sensor (or whatever) which would show in HA current preset on tuner?
I mainly change presets via HA. But, if someone “accidentally” switches station with remote control or with buttons on tuner then HA doesn’t know that. It would be nice to have some kind of return information about current preset in use…
I tried many possible commands, pretty much all from THIS site, but nothing works. Interesting thing is that rest command for switch preset (http://192.168.x.y/fsapi/SET/netRemote.nav.action.selectPreset?pin=1234&value=3), but if i then send “GET” instead of “SET” (http://192.168.x.y/fsapi/GET/netRemote.nav.action.selectPreset?pin=1234) i always get a result of 0 or 1, not actual preset number.

As per github-page (https://github.com/flammy/fsapi/blob/0f9ac20ea0110ae27e1b7fb3bd0fec1e30f087fe/FSAPI.md#netremotesysaudioeqpreset) the following command has to be used:
/fsapi/GET/netRemote.sys.audio.eqPreset?pin=1337&sid=643480027
As far as I know this hasn’t been implemented in frontier silicon integration, yet.
But mediaplayer shows (if playing) current radio station and song playing. Maybe you can create a template sensor of it, if this is sufficient for you.

Yeah, i tried that, too, thanks but i get response value 1 no matter which preset i have set, so, it’s not usefull. Also i need session ID, which i can get, but i guess it’s diffrerent each time, so here’s also a problem.

Yes, mediaplayer shows media info and station name. But, naming style is not consistent… say, my first station has “Radio 1DAB - name of artist and song” while my second station has naming style “Radio Aktual, song name” (note that first station has “-” as delimiter while second has “,” as delimiter). So, i can’t break (easily) this title into two as “station” and “song name” to get some usefill sensor for possible automations.
But i managed to make media info as scrolling in to my card, so it is a solution. I can’t do any automations with it, of course, it’s merely for my own information. Still, better than nothing.

This is strange! I’ve set up 4 radio stations and for all of them ‘-’ is the delimiter.

Try this, which gives the name of the radio station, only:

- platform: rest
  name: radiostation
  resource: http://192.168.x.y/fsapi/GET/netRemote.play.info.name?pin=1234
  json_attributes:
    - fsapiResponse
  value_template: '{{ value_json["fsapiResponse"]["value"]["c8_array"] }}' 
1 Like

Heinz, based on your suggestion i managed to create another sensor for song name currently playing:

- platform: rest
  name: current song
  resource: http://192.168.x.y/fsapi/GET/netRemote.play.info.text?pin=1234
  json_attributes:
    - fsapiResponse
  value_template: '{{ value_json["fsapiResponse"]["value"]["c8_array"] }}'
  scan_interval: 5

I also added more frequent scan interval, since default is 30 seconds, now i have pretty much instant response. I hope it won’t be too frequent…

I also figured it out why i missed this commands: i tested only those without “sid=…”. Now i see that many of those commands work even if i don’t write session id at the end.
But even if i would find these rest commands myself there’s no way that i could manage to put together correct “value_template” and “json_attributes” to get a decent output without your help. So, thanks again for your help!

I tried a lot to get the play_media service working with radio_browser. but no success :frowning:
it seems that the interpretation of DLNA of homeassistant mediaplayer and my frontier silicon devices are different.

any idea how to get it working is more than appreciated.

Anyone having issues with these scripts after upgrading HA to 2023.8? I’m no longer able to change stations, volume e.t.c using scripts. Going to investigate further however interested to know if anyone else is having issues?

Hi, any progress or break-through on this? Trying to switch to the presets of my Medion radio but no success yet. Any hints greatly appreciate.

I have a few Auna radios at home. Sadly i learned that there are two basic chips used in these radios: frontier silicon and “nuvoton”. This latter has way less functions you can control via HA, and those available are not so friendly. It’s hard to figure out which system is used unless you power device on and see, though… so buying via internet is more or less a gamble, but after two wrong models bought i think i managed to “filter them out” - frontier silicon model is using “undok” app, not “airmusic”. So, if you have wrong model then you’re stuck with shell commands.
If you can change volume with command below then your model is (sadly) nuvoton:

http:// 192.168.x.y/setvol?vol=12&mute=0