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
vladosam
(Vladimir)
January 14, 2018, 2:10pm
216
Thanks. I have that but sometimes it jumps more then it should like 0.1 or 0.15. I never figured why.
jonkristian
(Jon Kristian)
January 14, 2018, 8:01pm
217
Is it so that the automation for input_select is needed for the select to change radio station without having to press play afterwards?
Bob_NL
(Bob Visser)
January 14, 2018, 8:02pm
218
You can do that with an automation indeed.
jonkristian
(Jon Kristian)
January 14, 2018, 8:31pm
219
Thanks! It’s all working pretty good. I created a gist of what I’ve gathered, hope you all don’t mind.
Anything to improve upon here?
1 Like
vladosam
(Vladimir)
January 14, 2018, 8:41pm
220
I also use google tts to announce next station.
jonkristian
(Jon Kristian)
January 14, 2018, 8:43pm
221
It’s so perfect! I love the cube automations you guys did. Do you know if it’s possible to make it emphazise the pronunciation? The speech is a little dim, at least it is with the Norwegian language.
vladosam
(Vladimir)
January 14, 2018, 8:49pm
222
Somebody told me that amazon polly is better. But i don’t use it.
lojden
January 16, 2018, 8:13pm
223
Does this works with google home speakers too?
Bob_NL
(Bob Visser)
January 16, 2018, 8:24pm
224
For sure! I currently use 1 regular Google Home device, 3 Google Home mini’s and several Chromecast audio’s