I think it is all going to depend on your original source for your stream. Are you going to use something external like Logitech Media server or are you trying to use the Built in Alexa Spotify?
Either can work But they both have advantages/disadvantages
There is an existing Alexa service on IFTTT that you can use as your “If this”. Just select “Say a specific phrase”. You must have the IFTTT skill enabled on your Alexa for this to work.
You can then use the Webhooks service to trigger whatever it is you want to do in HA. You just pass it through a URL.
It’s a bit outdated (maybe I can figure out how to edit it and update it sometime this week). Just know that the “maker” service no longer exists, it’s now split into two different services, one of which is Webhooks.
Edit: I should also note that you need to be able to securely access your HA server remotely for this to work.
My first choice is Built in Alexa Spotify… but there is no possibility, I can choose local stream, Logitech Media Server or Plex… I also read something about PiMusicBox (Mopidy).
are you planning on using 1 Alexa device to control all of them or are you trying to use 1 alexa device as the main “music hub”. This is how I did it. Just so you know the only real downfall is that there is about a 3-6 second lag depending on how you have it setup.
With either way you are going to need access to a media server:
If you are using a DOT you are going to use the line out function. I would get a splitter and have a small speaker there for regular use. One line will need to go to your media server “ICECAST2” You would essentially pipe the line out audio to ICECAST2 and it will turn it into a stream via .ogg or .mp3 and you can send this stream to any of your chromecast audio devices.
If you are going to control the Spotify playlist from your phone of from Logitech media server then all you will need is a streaming URL with an MP3 or OGG section.
so just to recap, to use home assistant with chromecast audio you NEED some type of streaming URL that is in an audio format (MP3 ,OGG, etc…) and then there are multiple ways to execute, but first see how you want to implement the url.
I don’t understand what you mean by local streams, but my configuration is all on my GitHub. The package for the chromecast radio is probably the best example,which was adapted from this thread…
I tried different settings to setup a radio stream (http://80.86.106.143:9128/rockfm.aacp) for 1 chromecast but the HomeAssistant is crashing. Can you please help me with the configuration for this radio stream?
My chromecast entity_id is codis_chromecast and I want to create a stream called ‘Rock Stream’.
This is my configuration.yaml, and the HASS is down… it can’t be accessed anymore.
homeassistant:
# Name of the location where Home Assistant is running
name: Home
# Location required to calculate the time the sun rises and sets
latitude: 45.6333
longitude: 25.5833
# Impacts weather/sunrise data (altitude above sea level in meters)
elevation: 643
# metric for Metric, imperial for Imperial
unit_system: metric
# Pick yours from here: http://en.wikipedia.org/wiki/List_of_tz_database_time_zones
time_zone: Europe/Bucharest
customize:
script.radio538:
friendly_name: Start Playing
icon: mdi:play
# Show links to resources in log and frontend
# introduction:
# Enables the frontend
frontend:
# Enables configuration UI
config:
http:
# Uncomment this to add a password (recommended!)
api_password: !secret
# Uncomment this if you are using SSL or running in Docker etc
base_url: !secret
# 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:
# Track the sun
sun:
group:
Rock Radio:
name: Rock Radio
entities:
- input_select.radio_station
- input_select.chromecast_radio
- script.radio538
# Weather Prediction
sensor:
platform: yr
# Text to speech
tts:
platform: google
#Media players
media_player:
- platform: spotify
client_id: !secret
client_secret: !secret
- platform: kodi
name: Kodi Media Player
host: !secret
username: !secret
password: !secret
- platform: plex
- platform: cast
input_select:
radio_station:
name: 'Select Radio Station:'
options:
- Rock FM
- Radio ZU
chromecast_radio:
name: 'Select Speakers:'
options:
- Livingroom
- Bedroom
- Everywhere
initial: Everywhere
icon: mdi:speaker-wireless
script:
radio538:
alias: Play Radio on Chromecast Audio
sequence:
- service: media_player.volume_set
data:
entity_id: media_player.codis_chromecast
volume_level: '0.35'
- service: media_player.play_media
data_template:
entity_id: >
{% if is_state("input_select.chromecast_radio", "Livingroom") %} media_player.codis_chromecast
{% endif %}
media_content_id: >
{% if is_state("input_select.radio_station", "Rock FM") %} http://80.86.106.143:9128/rockfm.aacp
{% elif is_state("input_select.radio_station", "Radio ZU") %} http://77.81.25.2:9123/radiozu.aacp
{% endif %}
media_content_type: 'audio/mp4'
group: !include groups.yaml
automation: !include automations.yaml
I recommend simplifying first, that case you can expand your script piece by piece and find out were it goes wrong.
If I understand correctly, you only have 1 Chromecast device? If yes, you can lose the if statement on the entity_id part.
Start with this:
script:
radio538:
alias: Play Radio on Chromecast Audio
sequence:
- service: media_player.play_media
data_template:
entity_id: media_player.codis_chromecast
media_content_id: >
{% if is_state("input_select.radio_station", "Rock FM") %} http://80.86.106.143:9128/rockfm.aacp
{% elif is_state("input_select.radio_station", "Radio ZU") %} http://77.81.25.2:9123/radiozu.aacp
{% endif %}
media_content_type: 'audio/mp4'
You did setup your input_select.radio_station correctly?
How do you execute your script? Manual through the frontend?
Hi, many thanks for your help. Currently, I want to execute the script manually through the frontend, but I will want to create an automation to open the chromecast and start the stream.
Here is my setup for input_select:
input_select:
radio_station:
name: 'Select Radio Station:'
options:
- Rock FM
- Radio ZU
chromecast_radio:
name: 'Select Speakers:'
options:
- Livingroom
initial: Everywhere
icon: mdi:speaker-wireless