Try switching off the cast device instead of stopping. When stopping, it seems like it actually goes on pause (as you can press play again and it instantly resumes playing).
Could it be possible to add an option to send a notification with the title of the song played when casting to Chromecast? If yes, how?
Anybody know how to play a local playlist of mp3s? For instance, if you have 5 mp3s locally to hass, how do you stream them as a playlist?
There is a thread on this forum about using Mopidy and Icecast to play Spotify on Chromecast, from what I remember Mopidy can also play local files.
Edit: here is a good write-up https://www.vittoriomonaco.de/home-automation-part-7.html
Very nice write up but I don’t have the music collection to justify the effort. I’m looking for a simpler method, somehow to queue local songs. Something easy like separating songs by ‘;’ or simply supporting an m3u file that points to all the songs locally?
media_content_id: >
{% if is_state('input_select.music_station', 'Playlist 1') %} http://song1.mp3; http://song2.mp3; http://song3.mp3
Well, the thing is that a Chromecast itself cannot play a file, only a digital stream, so you need to convert your file to a stream and then send it to the CC.
It seems as you can use the included webserver to convert the files and then cast them to the CC, check this one: Can't play local audio file to chromecast audio (link goes to solution, not question). It should at least serve as a starting point, I don’t know if it will work with an m3u file.
I just used an mp3 joiner and called it a day for now
Has anybody used this successfully? media_player.media_seek to seek through an mp3? Ideally I would have an input_number as a slider. I wasn’t able to seek successfully.
- service: media_player.media_seek
data:
entity_id: media_player.office_speaker
seek_position: 50
retry code sample below
I don’t know what I’m doing wrong. I’ve been trying for 6 hours. (Thats me, a noob, new to .yaml and Hassio) I’ve never been able to get any part of this up and running. PS i have only one google chromecast.
I’ll post all codes im using below. Note: I have never been able to find a way to add the “input_slider:” part into my setup anywhere without Hassio config check failing or other errors.
###############Codes im using ##############
This part is in configuartion.yaml
####Selectors####
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
- Smooth Jazz Tampa
- Classic Rock Florida
- Bob Sinclar Radio
- Chill Out Zone
- 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:
- Living_room
- Everywhere
initial: Living_room
icon: mdi:speaker-wireless
This part is in automation.yaml
- alias: ‘Set Radio Volume’
trigger:
platform: state
entity_id: input_slider.volume_radio
action:
service: media_player.volume_set
data_template:
entity_id: media_player.living_room
volume_level: ‘{{ states.input_slider.volume_radio.state }}’
This part is in customize.yaml
script.radio538:
friendly_name: Start Playing
icon: mdi:play
This part is in groups.yaml
####Views####
media_view:
name: All Media
view: yes
entities:
- camera.logitech_usb_cam_1
- camera.win_ip_cam_1
- media_player.living_room
- group.residence_radio_group
####Groups####
residence_radio_group:
name: Internet Radio
entities:
- input_select.radio_station
- input_select.chromecast_radio
- script.radio538
- input_slider.volume_radio
This is in scripts.yaml
radio538:
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.living_room
{% elif is_state(“input_select.chromecast_radio”, “Everywhere”) %} media_player.home_group
{% endif %}
volume_level: ‘{{ states.input_slider.volume_radio.state }}’ - service: media_player.play_media
data_template:
entity_id: >
{% if is_state(“input_select.chromecast_radio”, “Livingroom”) %} media_player.living_room
{% elif is_state(“input_select.chromecast_radio”, “Everywhere”) %} media_player.home_group
{% endif %}
media_content_id: >
{% if is_state(“input_select.radio_station”, “Radio 538”) %} http://vip-icecast.538.lw.triple-it.nl:80/RADIO538_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”, “Smooth Jazz Tampa”) %} http://us3.internet-radio.com:8007/listen.mp3
{% elif is_state(“input_select.radio_station”, “Classic Rock Florida”) %} http://listen.shoutcast.com/Classic-RockFlorida
{% elif is_state(“input_select.radio_station”, “Bob Sinclar Radio”) %} http://listen.shoutcast.com/prysmradio09-mp3
{% elif is_state(“input_select.radio_station”, “Chill Out Zone”) %} http://air.chillout.zone:8000/radio
{% elif is_state(“input_select.radio_station”, “SLAM! Hardstyle”) %} http://stream.radiocorp.nl/web11_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’
Have never been able to put this in anywhere…
input_slider:
volume_radio:
name: Volume
icon: mdi:volume-high
min: 0
max: 1
step: 0.05
I have many other things configured and working
Below is complete configuration.yaml with secrets redacted.
#############Complete configuration.yaml###########
homeassistant:
Name of the location where Home Assistant is running
name: Home
Location required to calculate the time the sun rises and sets
latitude: -xx.xxxx
longitude: -xx.xxxx
Impacts weather/sunrise data (altitude above sea level in meters)
elevation: x
metric for Metric, imperial for Imperial
unit_system: imperial
Pick yours from here: http://en.wikipedia.org/wiki/List_of_tz_database_time_zones
time_zone: America/New_York
Customization file
customize: !include customize.yaml
Show links to resources in log and frontend (unComment the line below to show introduction)
introduction:
Enables the frontend
frontend:
themes: !include theme.yaml
Enables configuration UI
config:
http:
Secrets are defined in the file secrets.yaml
Uncomment this if you are using SSL/TLS, running in Docker container, etc.
base_url: https://xxxxx.xxxxxxx.xxx.xx.x.x.x.xxx.:xxxx
ssl_certificate: /ssl/fullchain.pem
ssl_key: /ssl/privkey.pem
api_password: !secret api_password
Checks for available updates
Note: This component will send some information about your system to
the developers to assist with development of Home Assistant.
For more information, please see:
https://home-assistant.io/blog/2016/10/25/explaining-the-updater/
updater:
Optional, allows Home Assistant developers to focus on popular components.
include_used_components: true
Discover some devices automatically
discovery:
Allows you to issue voice commands from the frontend in enabled browsers
conversation:
Enables support for tracking state changes over time
history:
View all events in a logbook
logbook:
Enables a map showing the location of tracked devices
map:
Track the sun
sun:
Platform systemmonitor displays CPU and Memory Usage Data , Platform darksky displays weather infromation.
sensor:
- platform: systemmonitor
resources:- type: disk_use_percent
arg: /home - type: memory_free
- type: load_1m
- type: network_in
arg: wlan0 - type: network_out
arg: wlan0 - type: processor_use
- type: since_last_boot
- type: last_boot
- type: disk_use_percent
- platform: darksky #
api_key: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
monitored_conditions:- summary
- icon
- nearest_storm_distance
- daily_summary
- precip_type
- precip_intensity
- precip_intensity_max
- precip_probability
- temperature
- temperature_max
- temperature_min
- apparent_temperature
- apparent_temperature_max
- apparent_temperature_min
- dew_point
- wind_speed
- wind_bearing
- cloud_cover
- humidity
- pressure
- visibility
- minutely_summary
- hourly_summary
- uv_index
update_interval: ‘00:30’
Text to speech
tts:
- platform: google
Cloud
cloud:
Group
group: !include groups.yaml
Automation
automation: !include automations.yaml
Script
script: !include scripts.yaml
All Custom Component Add-ons & Codes Belong Below /THIS LINE/
Start of Custom Component Add-ons & Codes
Device Tracker via NMAP
device_tracker:
- platform: nmap_tracker
hosts:- xx.xx.x.xxx-199
- xx.xx.x.xxx-170
home_interval: 10
exclude: - xx.xx.x.xxx-xxx
panel_iframe: !include panels.yaml
ifttt:
key: xxxxxxxxxxxxxxxxxxxxxxxxxx
camera:
- platform: local_file
name: logitech USB Cam 1
file_path: /share/motion/lastsnap.jpg - platform: mjpeg
name: Win IP Cam 1
mjpeg_url: http://xx.xx.x.xxx:xxxx/mjpeg
username: !secret winipcam1_username
password: !secret winipcam1_password
switch:
- platform: wake_on_lan
mac_address: “xx-xx-xx-xx-xx-xx”
####Selectors####
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
- Smooth Jazz Tampa
- Classic Rock Florida
- Bob Sinclar Radio
- Chill Out Zone
- 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:
- Living_room
- Everywhere
initial: Living_room
icon: mdi:speaker-wireless
@luisi.steve are you sure you are using the right entity names for your cast device? As it wouldn’t be very logical to create a group (Home Group) for 1 single device.
OHhhhhhh my Gosh… your right… it never saved my changes to the scripts file…
I never did create the group “home_group” at all was just going to use this with one cast device…
I still had this
service: media_player.volume_set
data_template:
entity_id: >
{% if is_state(“input_select.chromecast_radio”, “Livingroom”) %} media_player.living_room
{% elif is_state(“input_select.chromecast_radio”, “Everywhere”) %} media_player.home_group
{% endif %}
volume_level: ‘{{ states.input_slider.volume_radio.state }}’
service: media_player.play_media
data_template:
entity_id: >
{% if is_state(“input_select.chromecast_radio”, “Livingroom”) %} media_player.living_room
{% elif is_state(“input_select.chromecast_radio”, “Everywhere”) %} media_player.home_group
{% endif %}
not this.
radio538:
alias: Play Radio on Chromecast Audio
sequence:
- service: media_player.volume_set
data_template:
entity_id:
media_player.living_room
volume_level: '{{ states.input_slider.volume_radio.state }}'
- service: media_player.play_media
data_template:
entity_id:
media_player.living_room
media_content_id: >
{% if is_state("input_select.radio_station", "Radio 538") %} http://vip-icecast.538.lw.triple-it.nl:80/RADIO538_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", "Smooth Jazz Tampa") %} http://us3.internet-radio.com:8007/listen.mp3
{% elif is_state("input_select.radio_station", "Classic Rock Florida") %} http://listen.shoutcast.com/Classic-RockFlorida
{% elif is_state("input_select.radio_station", "Bob Sinclar Radio") %} http://listen.shoutcast.com/prysmradio09-mp3
{% elif is_state("input_select.radio_station", "Chill Out Zone") %} http://air.chillout.zone:8000/radio
{% elif is_state("input_select.radio_station", "SLAM! Hardstyle") %} http://stream.radiocorp.nl/web11_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'
“input_slider” has been replaced by “input_number”. Check out https://www.home-assistant.io/components/input_number/
Anybody got service: media_player.media_seek to work?
Is this possible with hass.io? Another poster earlier meantioned it not working but maybe things have changed?
Is it possible to do something like this:
icon: "{%- if is_state('input_number.radio_volume', '0')-%}mdi:volume-off{%- else -%}mdi:volume-high{%- endif -%}"
That’d be nice
Sure, use icon_template
:
icon_template: >
{%- if is_state('input_number.radio_volume', '0')-%} mdi:volume-off
{% else %} mdi:volume-high
{% endif %}
Ohh, sorry, I forgot to say I’ve tried using a template, but I can’t figure out the indentation. I’ve tried every variant I could think of…but it always complains. Below is my input_number.yaml.
radio_volume:
name: Volym
#icon: mdi:volume-high
#icon_template: >- "{%- if is_state('input_number.radio_volume', '0')-%}mdi:volume-off{%- else -%}mdi:volume-high{%- endif -%}"
icon_template: > {%- if is_state('input_number.radio_volume', '0')-%} mdi:volume-off{% else %} mdi:volume-high{% endif %}
min: 0
max: 1
step: 0.05
mode: slider
Anyone using media_extractor? For some reason my previous code is not working. Earlier it worked flawlessly to extract audio from any YouTube URL and play to Google Home speaker.
Now it starts streaming then stops after few minutes. There were no errors in the log file.
This is awesome! At first I was disappointed because there wasn’t a way to use Pandora playlists. However I’ve been scouring Iheart radio and other streaming sites and I’ve been able to get stream URLs to most of the music I like. I’m not sure if a true Pandora component is possible, but this is a close 2nd.