Anyone that know how to get this station to work with this setup?
#https://tunein.com/radio/JULRADIOse-s236911/
This is the .pls file when i open it:
[playlist]
File1=http://relay1.julradio.se:80
Title1=Relay #1 (Port80 Jobb/Arbete) - JULRADIO.se
Length1=-1
File2=http://relay1.julradio.se:9000
Title2=Relay #2 - JULRADIO.se
Length2=-1
File3=http://relay2.julradio.se:80
Title3=Relay #3 (Port80 Jobb/Arbete) - JULRADIO.se
Length3=-1
File4=http://relay2.julradio.se:9000
Title4=Relay #4 - JULRADIO.se
Length4=-1
File5=http://relay1.julradio.se:443
Title5=Relay #5 (Port443 Jobb/Arbete) - JULRADIO.se
Length5=-1
File6=http://relay2.julradio.se:443
Title6=Relay #6 (Port443 Jobb/Arbete) - JULRADIO.se
Length6=-1
Freland
(Fredrik Nilsson)
December 4, 2017, 4:21pm
197
Hi! Thanks for the awesome work with the radio setup! However, I’m having some issues. The playback fails waay too often for some reason. Here are some examples:
I can’t use the group with my two Chromecast audios (group everywhere), I can hear it connect (with the blip), but nothing starts
Once I have started music in one of the audios I can’t switch to another speaker.
It generally feels a bit unstable since I can’t restart with the “Activate” button - Only way to get it up and running is to restart home assistant.
Here is my code, hope someone can spot errors:
script:
julradio:
alias: Play Radio on Chromecast Audio
sequence:
- service: media_player.volume_set
data_template:
entity_id: >
{% if is_state("input_select.chromecast_radio", "Livingroom") %} media_player.frellenvardagsrum
{% elif is_state("input_select.chromecast_radio", "Library") %} media_player.frellenbibliotek
{% elif is_state("input_select.chromecast_radio", "Everywhere") %} media_player.frellenhome
{% endif %}
volume_level: '{{ states.input_number.volume_radio.state }}'
- service: media_player.play_media
data_template:
entity_id: >
{% if is_state("input_select.chromecast_radio", "Livingroom") %} media_player.frellenvardagsrum
{% elif is_state("input_select.chromecast_radio", "Library") %} media_player.frellenbibliotek
{% elif is_state("input_select.chromecast_radio", "Everywhere") %} media_player.frellenhome
{% endif %}
media_content_id: >
{% if is_state("input_select.radio_station", "Christmas P4") %} http://sverigesradio.se/topsy/direkt/3034-hi-mp3.mp3
{% elif is_state("input_select.radio_station", "Christmas P2") %} http://sverigesradio.se/topsy/direkt/3036-hi-mp3.mp3
{% endif %}
media_content_type: 'audio/mp4'
input_select:
radio_station:
name: 'Select Radio Station:'
options:
- Christmas P4
- Christmas P2
- Test
initial: Christmas P4
chromecast_radio:
name: 'Select Speakers:'
options:
- Livingroom
- Library
- Everywhere
initial: Everywhere
icon: mdi:speaker-wireless
input_number:
volume_radio:
name: Volume
icon: mdi:volume-high
initial: 0.3
min: 0
max: 1
step: 0.05
group:
julradio:
name: Julradio
entities:
- input_select.radio_station
- input_select.chromecast_radio
- script.julradio
- input_number.volume_radio
Any ideas on how to make it work better?
Bob_NL
(Bob Visser)
December 6, 2017, 8:45pm
198
Than you probably are using faulty links, check them in your browser (should play instantly without having to press a play button).
You should be able to switch by selecting your speakers and pressing play again. If you add a media_player.media_stop
command in the script than the music stops on the prvious players before starting it on the other speakers.
That’s weird, I don’t recognize this behaviour. Check your logfile for errors. Are u using a Raspberry? Are you using an adapter with sufficiant amperage?
kepler
December 27, 2017, 3:33pm
199
I have been using this code for a while and it works great! Many thanks for the work. But now I wanted to add Volume+ and Volume- buttons instead of the slider.
I found the media_player.volume_up and this work very good. But the volume-steps are too big…
So I found this and want to use it as a script:
volume_up:
alias: Volume +
sequence:
- service: media_player.volume_set
data_template:
entity_id: >
{% if is_state("input_select.chromecast_radio", "Huiskamer") %} media_player.speakers_huiskamer
{% elif is_state("input_select.chromecast_radio", "Zolder") %} media_player.speakers_zolder
{% elif is_state("input_select.chromecast_radio", "Overal") %} media_player.huis
{% endif %}
data_template:
volume_level: '{{ states.media_player.YourPlayer.attributes.volume_level + 5 }}'
But now I am stuck, since I don’t know how to use the correct current volume level (ie the current chromecast being used) at the last step? I am quite a beginner in programming, but I can’t figure it out… Any help/tips would be appreciated!
Bob_NL
(Bob Visser)
December 27, 2017, 4:05pm
200
kepler:
But now I am stuck, since I don’t know how to use the correct current volume level (ie the current chromecast being used) at the last step? I am quite a beginner in programming, but I can’t figure it out… Any help/tips would be appreciated!
The volume increments in steps of .5 so you might want to change this. If you are ok with the volume being changed to the selected speakers in your input_select, you could try like this:
volume_up:
alias: Volume +
sequence:
- service: media_player.volume_set
data_template:
entity_id: >
{% if is_state("input_select.chromecast_radio", "Huiskamer") %} media_player.speakers_huiskamer
{% elif is_state("input_select.chromecast_radio", "Zolder") %} media_player.speakers_zolder
{% elif is_state("input_select.chromecast_radio", "Overal") %} media_player.huis
{% endif %}
volume_level: >
{% if is_state("input_select.chromecast_radio", "Huiskamer") %} '{{ (states.media_player.speakers_huiskamer.attributes.volume_level | float) + 0.5 }}'
{% elif is_state("input_select.chromecast_radio", "Zolder") %} '{{ (states.media_player.speakers_zolder.attributes.volume_level | float) + 0.5 }}'
{% elif is_state("input_select.chromecast_radio", "Overal") %} '{{ (states.media_player.huis.attributes.volume_level | float) + 0.5 }}'
{% endif %}
daanje
(Daniel Palstra)
December 27, 2017, 8:19pm
201
Great sample @Bob_NL . I’ve put all config in a package and I am using an Automation that triggers the script when a station is selected.
group:
radio:
name: Radio
entities:
- input_select.radio_station
- input_select.chromecast_radio
input_select:
radio_station:
name: 'Select Radio Station:'
options:
- Radio 538
- Q-Music
- 3FM
- 100% NL
- Veronica
- Sky Radio
- Arrow Classic Rock
- Classic FM
- BNR Nieuwsradio
- SLAM! Hardstyle
- Sleep Radio
- Ambient Sleeping Pill
- Radio Art - Sleep
- Ambi Nature Radio
- Calm Radio - Sleep
- Dinamo.FM Sleep
chromecast_radio:
name: 'Select Speakers:'
options:
- Livingroom
- Everywhere
initial: Livingroom
icon: mdi:speaker-wireless
automation:
alias: Listen Radio
hide_entity: True
trigger:
- platform: state
entity_id: input_select.radio_station
action:
- service: script.radio
script:
radio:
alias: Play Radio on Chromecast Audio
sequence:
- service: media_player.select_source
entity_id: media_player.denon_avrx1300w
data:
source: 'AUX'
- service: media_player.play_media
data_template:
entity_id: >
{% if is_state("input_select.chromecast_radio", "Livingroom") %} media_player.huiskamer
{% elif is_state("input_select.chromecast_radio", "Everywhere") %} media_player.huiskamer
{% endif %}
media_content_id: >
{% if is_state("input_select.radio_station", "Radio 538") %} http://playerservices.streamtheworld.com/api/livestream-redirect/TLPSTR01.mp3
{% elif is_state("input_select.radio_station", "Q-Music") %} http://icecast-qmusic.cdp.triple-it.nl/Qmusic_nl_live_96.mp3
{% elif is_state("input_select.radio_station", "3FM") %} http://icecast.omroep.nl/3fm-bb-mp3
{% elif is_state("input_select.radio_station", "100% NL") %} http://stream.100p.nl/100pctnl.mp3
{% elif is_state("input_select.radio_station", "Veronica") %} http://8543.live.streamtheworld.com/VERONICACMP3
{% elif is_state("input_select.radio_station", "Sky Radio") %} http://8623.live.streamtheworld.com:80/SKYRADIOAAC_SC
{% elif is_state("input_select.radio_station", "Arrow Classic Rock") %} http://91.221.151.155/listen.mp3
{% elif is_state("input_select.radio_station", "Classic FM") %} http://19143.live.streamtheworld.com/CLASSICFM_SC
{% elif is_state("input_select.radio_station", "BNR Nieuwsradio") %} http://icecast-bnr.cdp.triple-it.nl/bnr_mp3_96_03
{% elif is_state("input_select.radio_station", "SLAM! Hardstyle") %} http://vip-icecast.538.lw.triple-it.nl/WEB17_MP3
{% elif is_state("input_select.radio_station", "Sleep Radio") %} http://37.59.28.208:8722/stream
{% elif is_state("input_select.radio_station", "Ambient Sleeping Pill") %} http://perseus.shoutca.st:8447/h
{% elif is_state("input_select.radio_station", "Radio Art - Sleep") %} http://live.radioart.com/fSleep.mp3
{% elif is_state("input_select.radio_station", "Ambi Nature Radio") %} http://94.23.252.14:8067/stream
{% elif is_state("input_select.radio_station", "Calm Radio - Sleep") %} http://streams.calmradio.com/api/39/128/stream
{% elif is_state("input_select.radio_station", "Dinamo.FM Sleep") %} http://channels.dinamo.fm/sleep-aac
{% endif %}
media_content_type: 'audio/mp4'
2 Likes
Bob_NL
(Bob Visser)
December 27, 2017, 9:54pm
202
You could trigger the whole radio from that same automation too if you want it to play directly after selecting a stream. Or would you still like to keep the play button?
daanje
(Daniel Palstra)
December 28, 2017, 7:22pm
203
I’m keeping the play button to turn on the radio if the station I want to listen to is already selected
1 Like
kepler
December 30, 2017, 5:56am
204
Thanks, getting a bit closer but getting the following error:
Invalid service data for media_player.volume_set: expected float for dictionary value @ data['volume_level']. Got "'5.100000001490116'"
Does this have to do rounding the number or something?
Bob_NL
(Bob Visser)
December 30, 2017, 10:26pm
205
Try this:
volume_level: >
{% if is_state("input_select.chromecast_radio", "Huiskamer") %} '{{ ((states.media_player.speakers_huiskamer.attributes.volume_level) + 0.5) | float }}'
{% elif is_state("input_select.chromecast_radio", "Zolder") %} '{{ ((states.media_player.speakers_zolder.attributes.volume_level) + 0.5) | float }}'
{% elif is_state("input_select.chromecast_radio", "Overal") %} '{{ ((states.media_player.huis.attributes.volume_level) + 0.5) | float }}'
{% endif %}
Bob_NL
(Bob Visser)
December 31, 2017, 12:03pm
206
I see whats wrong now, loose the quotes.
so:
volume_level: >
{% if is_state("input_select.chromecast_radio", "Huiskamer") %} {{ (states.media_player.speakers_huiskamer.attributes.volume_level | float) + 0.5 }}
{% elif is_state("input_select.chromecast_radio", "Zolder") %} {{ (states.media_player.speakers_zolder.attributes.volume_level | float) + 0.5 }}
{% elif is_state("input_select.chromecast_radio", "Overal") %} {{ (states.media_player.huis.attributes.volume_level | float) + 0.5 }}
{% endif %}
kepler
January 1, 2018, 9:29am
207
Nice, this works! Thanks! Could you explain why the quotes need to be removed?
kepler
January 1, 2018, 10:54am
208
I’ve been playing with the code a bit and slowly learning more and more about HomeAssistant
Now I have the following code, based on Bob_NL and Daanje (for the automated start after selection). This is only for one room, still trying to figure out what works best. The idea now is to have tab for every room (and thus radio option for each room).
This is the code for the Script:
radio_huiskamer:
alias: Play Radio
sequence:
- service: media_player.volume_set
data_template:
entity_id: media_player.speakers_huiskamer
volume_level: 0.2
- service: media_player.play_media
data_template:
entity_id: media_player.speakers_huiskamer
media_content_id: >
{% if is_state("input_select.radio_station_huiskamer", "Radio 538") %} http://18973.live.streamtheworld.com/RADIO538.mp3
{% elif is_state("input_select.radio_station_huiskamer", "Q-Music") %} http://icecast-qmusic.cdp.triple-it.nl/Qmusic_nl_live_96.mp3
{% elif is_state("input_select.radio_station_huiskamer", "3FM") %} http://icecast.omroep.nl/3fm-bb-mp3
{% elif is_state("input_select.radio_station_huiskamer", "100% NL") %} http://stream.100p.nl/100pctnl.mp3
{% elif is_state("input_select.radio_station_huiskamer", "Veronica") %} http://8543.live.streamtheworld.com/VERONICACMP3
{% elif is_state("input_select.radio_station_huiskamer", "Sky Radio") %} http://8623.live.streamtheworld.com:80/SKYRADIOAAC_SC
{% elif is_state("input_select.radio_station_huiskamer", "Arrow Classic Rock") %} http://91.221.151.155/listen.mp3
{% elif is_state("input_select.radio_station_huiskamer", "Classic FM") %} http://19143.live.streamtheworld.com/CLASSICFM_SC
{% elif is_state("input_select.radio_station_huiskamer", "BNR Nieuwsradio") %} http://icecast-bnr.cdp.triple-it.nl/bnr_mp3_96_03
{% endif %}
media_content_type: 'audio/mp4'
stopradio_huiskamer:
alias: Stop radio
sequence:
- service: media_player.media_stop
data_template:
entity_id: media_player.speakers_huiskamer
volume_up_huiskamer:
alias: Volume +
sequence:
- service: media_player.volume_set
data_template:
entity_id: media_player.speakers_huiskamer
volume_level: >
{{ (states.media_player.speakers_huiskamer.attributes.volume_level | float) + 0.01 }}
volume_down_huiskamer:
alias: Volume -
sequence:
- service: media_player.volume_set
data_template:
entity_id: media_player.speakers_huiskamer
volume_level: >
{{ (states.media_player.speakers_huiskamer.attributes.volume_level | float) - 0.01 }}
devray
(Raimund A.)
January 9, 2018, 7:40pm
209
How can i see the name of the station instead of Default Media Receiver?!
Are there any ideas, i have got an streaming URL that returns the title of the
played song!
mrpinapple
(Mrpinapple)
January 13, 2018, 1:23pm
210
Hey guys, if you did not find out yet - There is an easy way to get almost every .pls stream to work.
Download .pls file
Open .pls file with notepad++
search for the “File1” line e.g. “File1=http://xy.station.fm:8000”
copy URL and extend it with “/;stream.mp3” e.g. “http://xy.station.fm:8000/;stream.mp3 ”
use the extended URL and enjoy
thanks to: Cannot stream *.pls radio stream to chromecast
1 Like
jonkristian
(Jon Kristian)
January 14, 2018, 11:02am
211
Would it be possible to see your cube configuration to control the radio?
vladosam
(Vladimir)
January 14, 2018, 11:25am
212
Of course. With cube i only control input select with radio station names. Flip 90 select next in input select. Flip 180 select previous. Shake turn on and off.
- id: '2005'
alias: 'radio play with cube'
trigger:
- platform: event
event_type: cube_action
event_data:
entity_id: binary_sensor.cube_158d000106132f
action_type: shake_air
condition:
- condition: template
value_template: >
{% if is_state('media_player.chromecastaudio0667', 'off') %}
true
{% else %}
false
{% endif %}
action:
- service: switch.turn_on
entity_id: switch.orvibo
- service: input_number.set_value
data:
entity_id: input_number.volume_radio
value: '0.15'
- service: media_player.volume_mute
data:
entity_id: media_player.chromecastaudio0667
is_volume_muted: "false"
- service: input_select.select_option
entity_id: input_select.radio_station
data:
option: "Antena"
- id: '2006'
alias: 'radio next station with cube'
trigger:
- platform: event
event_type: cube_action
event_data:
entity_id: binary_sensor.cube_158d000106132f
action_type: flip90
condition:
- condition: template
value_template: >
{% if is_state('media_player.chromecastaudio0667', 'playing') %}
true
{% else %}
false
{% endif %}
action:
- service: input_select.select_next
entity_id: input_select.radio_station
- id: '2007'
alias: 'radio previous station with cube'
trigger:
- platform: event
event_type: cube_action
event_data:
entity_id: binary_sensor.cube_158d000106132f
action_type: flip180
condition:
- condition: template
value_template: >
{% if is_state('media_player.chromecastaudio0667', 'playing') %}
true
{% else %}
false
{% endif %}
action:
- service: input_select.select_previous
entity_id: input_select.radio_station
- id: '2008'
alias: 'radio set volume with cube'
trigger:
- platform: event
event_type: cube_action
event_data:
entity_id: binary_sensor.cube_158d000106132f
action_type: rotate
action:
- service: input_number.set_value
data_template:
entity_id: input_number.volume_radio
value: >
{%if trigger.event.data.action_value | float > 0 %}
{{ states.input_number.volume_radio.state |float + 0.05 }}
{% else %}
{{ states.input_number.volume_radio.state |float - 0.05 }}
{% endif %}
- id: '2009'
alias: 'radio stop with cube'
trigger:
- platform: event
event_type: cube_action
event_data:
entity_id: binary_sensor.cube_158d000106132f
action_type: shake_air
condition:
- condition: template
value_template: >
{% if is_state('media_player.chromecastaudio0667', 'playing') %}
true
{% else %}
false
{% endif %}
action:
- service: input_select.select_option
entity_id: input_select.radio_station
data:
option: "Off"
4 Likes
jonkristian
(Jon Kristian)
January 14, 2018, 12:29pm
213
Thank you so much! Works great. I have one question however, how is your script when stopping? I see you have a option: "Off"
in your action there but not sure how to add it to the script, any pointers?
Bob_NL
(Bob Visser)
January 14, 2018, 1:00pm
214
Nice, here’s an automation to control the volume using the cube (rotate to right = volume up, rote to left = volume down.
- alias: Xiaomi Cube - Volume [Rotate]
trigger:
platform: event
event_type: cube_action
event_data:
entity_id: binary_sensor.cube_158d000101bded
action_type: rotate
condition:
- condition: state
entity_id: input_select.cube_mode
state: 'Radio'
action:
- service: media_player.volume_set
data_template:
entity_id: media_player.home_group
volume_level: >
{%if trigger.event.data.action_value | float > 0 %}
{{ states.media_player.home_group.attributes.volume_level | float + 0.05 }}
{% else %}
{{ states.media_player.home_group.attributes.volume_level | float - 0.05 }}
{% endif %}
Works great!
1 Like
vladosam
(Vladimir)
January 14, 2018, 2:06pm
215
This automation stops chromecast.
- id: '2002'
alias: 'radio stop'
trigger:
- platform: state
entity_id: input_select.radio_station
to: "Off"
action:
- service: media_player.media_stop
entity_id: media_player.chromecastaudio0667