Play Media - Radio Presets on Onkyo Receiver?

I’ve done a search here and via Google but can’t figure this out. I added my Onkyo receiver (wired) to HA via the recommended code in configurations.yaml

# Onkyo
media_player:
  - platform: onkyo
    host: 192.168.1.31
    name: Onkyo
    sources:
      fm: 'FM'

I then created a script for each radio preset

'1589041870809':
  alias: 107-9
  sequence:
  - data: {}
    entity_id: media_player.onkyo
    service: media_player.turn_on
  - data:
      source: fm
    entity_id: media_player.onkyo
    service: media_player.select_source
  - data:
      media_content_id: preset1
      media_content_type: music
    entity_id: media_player.onkyo
    service: media_player.play_media

I think the media_content_id is wrong but I have tried ‘1’ as well as the station number ('107.9) and also ‘preset=1’

Any guidance for the correct way to call a preset FM radio station is greatly appreciated.

Hi,
it should be:

  - service: media_player.play_media
    entity_id: media_player.YourOnkyo
    data:
      media_content_id: 1
      media_content_type: radio

Check out my solution to select presets from menu. This is not very convinient in programming but quite convinient in GUI:

media_player:
  - platform: onkyo
    host: !secret onkyo_ip
    name: Onkyo Receiver
    sources:
      fm: 'FM Radio'

input_select:
  radio_station:
    name: FM radio
    options:
      - Europa Plus
      - Retro FM
      - Radio 7
      - Studio21
      - Novoe Radio
      - Dorognoe Radio
      - Love Radio
      - NRJ
      - DFM
      - Mayak
    initial: Europa Plus
    icon: mdi:radio

…and the script corresponding input_select radoiostation title to Onkyo preset:

onkyo_fm:
  alias: 'Onkyo: Select FM Radio preset'
  sequence:
  - service: media_player.turn_on
    data:
      entity_id: media_player.onkyo_receiver
  - service: media_player.select_source
    data:
      entity_id: media_player.onkyo_receiver
      source: fm
  - service: media_player.play_media
    data_template:
      entity_id: media_player.onkyo_receiver
      media_content_type: radio
      media_content_id: '{%   if is_state("input_select.radio_station", "Europa Plus")
        %}1 {%-elif is_state("input_select.radio_station", "Retro FM")%}2 {%-elif
        is_state("input_select.radio_station", "Radio 7") %}3 {%-elif is_state("input_select.radio_station",
        "Studio21") %}4 {%-elif is_state("input_select.radio_station", "Novoe Radio")
        %}5 {%-elif is_state("input_select.radio_station", "Dorognoe Radio") %}6 {%-elif
        is_state("input_select.radio_station", "Love Radio") %}7 {%-elif is_state("input_select.radio_station",
        "NRJ") %}8 {%-elif is_state("input_select.radio_station", "DFM") %}9 {%-elif
        is_state("input_select.radio_station", "Mayak") %}10 {% endif %}'

…and the automation for switch preset just when I change input_select vaule:

- id: Tune-FM-preset
  alias: Select FM radio preset automatically
  trigger:
  - entity_id: input_select.radio_station
    platform: state
  action:
  - service: script.onkyo_fm

Screenshot 2020-05-10 at 17.07.06

Thank you very much for the fast reply and the cleaner setup (I was going to use buttons for each preset).

One question and one issue.

How would you turn on both the main and Zone 2 for the above?

I put in the following in configuration.yaml but am getting an error that reads:
Invalid config for [input_select]: initial state Onkyo radio is not part of the options: Kiss 108,Magic 106-7,Mix 104-1,Amp 103-3,WZLX 100-7,Classical 99-5,Hot 96-9 for dictionary value @ data[‘input_select’][‘radio_station’]. Got OrderedDict([(‘name’, ‘FM radio’), (‘options’, [‘Kiss 108’, ‘Magic 106-7’, ‘Mix 104-1’, ‘Amp 103-3’, ‘WZLX 100-7’, ‘Classical 99-5’, ‘Hot 96-9’]), (‘initial’, ‘Onkyo radio’), (‘icon’, ‘mdi:radio’)]). (See /config/configuration.yaml, line 162).

This is my section of configuration.yaml

# Onkyo
media_player:
  - platform: onkyo
    host: 192.168.1.31
    name: Onkyo
    sources:
      fm: 'FM Radio'

input_select:
  radio_station:
    name: FM radio
    options:
      - Kiss 108
      - Magic 106-7
      - Mix 104-1
      - Amp 103-3
      - WZLX 100-7
      - Classical 99-5
      - Hot 96-9
    initial: Onkyo radio
    icon: mdi:radio

I don’t use Zone 2 at all. :roll_eyes:

However Zone 2 is a separate mediaplayer so you need to apply all the same to media_player.onkyo_receiver_zone_2, just make a second script and add second action to automation (which fires up this second script).

There’s an error in input_select:
your input_select.radio_station have 7 optional values (from Kiss to Hot), but you don’t have initial value “Onkyo radio” in this list. Change this value to “Kiss 108” and voila.

D’oh! Didn’t understand what Initial meant and now very obvious.

I have it working and this is awesome. So clean. Thank you!

Now to get a little fancier if you will:

  1. What card are you using? I chose Entity Card and pulled input_select.radio_station but this is clunky as I need to click the name of the radio station and then, in the popup, pull down the one I want.
  2. Is it possible to add power off?
  3. Possible to adjust volume?
  4. Assuming a Zone 2, how would you cleanly select both from one card (or is that even possible)?
  1. I have Entities Card and have no worries with it. :slight_smile:
  2. Yes. Create a button with media_player.turn_off. And check your available media_player services in http://homeassistant.local:8123/developer-tools/service
  3. There’s a tricky trick for volume. You need not only pass volume value from GUI slider to Onkyo but also set slider value as you change volume on Onkyo by remote or volume dial on front panel. So here we are:
input_number:
  onkyo_volume:
    name: Onkyo Volume
    initial: 30
    min: 0
    max: 60
    step: 1

and automation:

- id: Onkyo_Volume_Set
  alias: Onkyo Volume Slider Set
  trigger:
  - platform: state
    entity_id: input_number.onkyo_volume
  condition:
  - condition: state
    entity_id: media_player.onkyo_receiver
    state: 'on'
  action:
  - service: media_player.volume_set
    data_template:
      entity_id: media_player.onkyo_receiver
      volume_level: '{{ states.input_number.onkyo_volume.state | float / 80 }}'
- id: Onkyo_Volume_Get
  alias: Onkyo Volume Slider Get
  trigger:
    platform: state
    entity_id: media_player.onkyo_receiver
  action:
    service: input_number.set_value
    data_template:
      entity_id: input_number.onkyo_volume
      value: '{{ states.media_player.onkyo_receiver.attributes.volume_level | float
        * 80 }}'

Also you can make two simple buttons with media_player.volume_up / media_player.volume_down services.
Screenshot 2020-05-10 at 18.36.49

  1. I don’t know :slight_smile:
1 Like

Looks like it was MUCH easier than I thought!

Used the Entities card with:

entities:
  - entity: media_player.onkyo
  - entity: media_player.onkyo_zone_2
  - entity: input_select.radio_station
  - entity: input_select.radio_station2
title: FM Radio
type: entities

So I ended up with Zone 1 power, zone 2 power and drop down for station preset.

When I pull down to get a station, power turns on for main zone and, magically, a volume appears! If I click on Zone 2, I get another volume option and, by default, it plays the same source

WOO HOO!!!

I see Net (ie Pandora) is specifically noted to not work. Don’t suppose you figured this one out…

Great decision. Congratulations!

About NET (TuneIn, Pandora etc): I tried to figure out once but I didn’t find a convinient way to manage TuneIn presets inside Onkyo without HDMI-display and IR-controler. I thought http://onkyo.local/station.cgi page is useless for saving/editing presets so I just left it.