I’m trying to configure an FM radio device to be controlled by IR as a universal media player.
I defined the list of radio channels as an input_select.
I have defined an automation that, when the selected element changes, executes scripts, each of them sends the relevant IR code via a Broadlink switch.
When I change the selection through the input_select displayed on the home page everything works perfectly.
The channel change done through the channel list displayed inside the universal media player does not work.
I have done dozens of different attempts but I can not make it work in any way.
Here are my configurations:
Input_select
studio_radio_elenco_canali:
name: Elenco canali radio studio
options:
- '1 Radio Deejay'
- '2 Radio Capital'
- '3 Radio Montecarlo'
- '4 Virgin Radio'
- '5 RDS'
- '6 Radio Nostalgia'
- '7 RAI Radio 1'
- '8 RAI Radio 2'
- '9 RAI Radio 3'
initial: 1 Radio Deejay
icon: mdi:radio
One more thing, if you want to add stations in the future, you’ll have to do a lot of editing. To alleviate that issue, you could always deal with a different method than what you are currently doing.
If you are dead set on numbering your channels you could split your channel name based on space (' ') and pull the first item, which should be the number.
You’d just need to maintain a channel number and script number. To add a new channel, you’d just make a script and add the input option. As opposed to adding a script, adding the input option, and adding if statements where needed.
The first method you’ve suggested works great. In your code was missing only the item entity_id after data_template.
In the source of the media player remains selected the previous item, but I solved it by adding a call to input_select.select_option within each script of changing channel.
The second method, which is certainly more elegant and which I like a lot, unfortunately does not work.
I am trying to do the same, but I am not very succesfull at it unfortunately.
What am I doing wrong in below code?
I have the sources, and I can select them, but then the scripts don’t get executed.
This whole section is alittle off. Your problem here is that you’ve added an entity_id and then you try to give it a second entity. Also, the first entity_id you provide is not in the same domain as the service call. I.E. You are running the script.turn_on service with the entity_id of media_player.select_source. I think all you need to do is replace media_player.select_source with a carrot >.