I want to integrate somehow Alexa with Chromecast Audio through HomeAssistant.
I have 2 Chromecast Audio and my idea is to create 2 separate streams for each Chromecast (local stream or Spotify if is possible). And get them controlled by Alexa (commands like ‘Alexa, turn on X stream’, ‘Alexa, turn off Y stream’).
Can you please tell me if there is any possibility to do this and how?
The best way I know of to send commands to HA from Alexa is to use IFTTT and webhooks. I hope that someone else knows of a better way because I use this method and I don’t like having to rely upon a third party service (beyond Alexa in this case).
As for controlling streams on Chromecast through HA, I don’t know much about that unfortunately but I’m also interested to learn as I have two Chromecasts at home.
Edit: I’ll also add that sending commands to HA through IFTT on Alexa requires the use of the word “trigger” in addition to your command. For instance: “Alexa, trigger TV on.”
Thank you for your reply. I do not know how IFTTT works for HA and Alexa. But from what I searched on Internet, there is a tutorial who explains how to create a sort of skill for Alexa to integrate with HomeAssistant:
I did not create this skill yet, but I plan to. Until this I’m trying to find out if it is possible and how to create separate streams for each Chromecast Audio.
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