Google Cast


Configuration

Adding Google Cast to your Home Assistant instance can be done via the user interface, by taking the following steps:

  • Browse to your Home Assistant instance.
  • In the sidebar click on Configuration.
  • From the configuration menu select: Integrations.

Google Cast can be auto-discovered by Home Assistant. If an instance was found, it will be shown in the top of the list of integrations as “Discovered”. If that is the case click on the Configure button to start setting up the discovered instance.

If there wasn’t any discovered automatically, don’t worry! You can set up a manual integration entry:

  • In the bottom right, click on the Add Integration button.
  • From the list, search and select “Google Cast”.
  • Follow the instruction on screen to complete the set up.

After completing, the Google Cast integration will be immediately available for use.

Support for mDNS discovery in your local network is mandatory. Make sure that your router has this feature enabled. This is even required if you entered the IP addresses of the Cast devices are manually in the configuration as mentioned below.

Options

Options for Google Cast can be set via the user interface, by taking the following steps:

  • Browse to your Home Assistant instance.
  • In the sidebar click on Configuration.
  • From the configuration menu select: Integrations.
  • If multiple instances of Google Cast are configured, choose the instance you want to configure.
  • Click on “Options”.
Known hosts

A comma-separated list of hostnames or IP-addresses of cast devices, use if mDNS discovery is not working

Allowed UUIDs

A comma-separated list of UUIDs of Cast devices to add to Home Assistant. Use only if you don’t want to add all available devices. The device won’t be added until discovered through either mDNS or if it’s included in the list of known hosts. In order to find the UUID for your device use a mDNS browser or advanced users can use the following Python command (adjust friendly names as required) - python3 -c "import pychromecast; print(pychromecast.get_listed_chromecasts(friendly_names=['Living Room TV', 'Bedroom TV', 'Office Chromecast'])). This option is only visible if advanced mode is enabled in your user profile.

Ignore CEC

A comma-separated list of Chromecasts that should ignore CEC data for determining the active input. See the upstream documentation for more information.. This option is only visible if advanced mode is enabled in your user profile.

Home Assistant Cast

Home Assistant has its own Cast application to show the Home Assistant UI on any Chromecast device. You can use it by adding the Cast entity row to your Lovelace UI, or by calling the cast.show_lovelace_view service. The service takes the path of a Lovelace view and an entity ID of a Cast device to show the view on. A path has to be defined in your Lovelace YAML for each view, as outlined in the views documentation. The dashboard_path is the part of the Lovelace UI URL that follows the defined base_url Typically “lovelace”. The following is a full configuration for a script that starts casting the downstairs tab of the lovelace-cast path (note that entity_id is specified under data and not for the service call):

cast_downstairs_on_kitchen:
  alias: "Show Downstairs on kitchen"
  sequence:
    - data:
        dashboard_path: lovelace
        entity_id: media_player.kitchen
        view_path: downstairs
      service: cast.show_lovelace_view

Home Assistant Cast requires your Home Assistant installation to be accessible via https://. If you’re using Home Assistant Cloud, you don’t need to do anything. Otherwise you must make sure that you have configured the external_url in your configuration.

Casting other apps

YouTube

  • app_name: youtube
  • media_id: YouTube video ID

Optional:

  • enqueue: Enqueue only
  • playlist_id: Play video with media_id from this playlist
'cast_youtube_to_my_chromecast':
  alias: "Cast YouTube to My Chromecast"
  sequence:
    - target:
        entity_id: media_player.my_chromecast
      data:
        media_content_type: cast
        media_content_id: '
          {
            "app_name": "youtube",
            "media_id": "dQw4w9WgXcQ"
          }'
      service: media_player.play_media

Supla

Example values to cast the item at https://www.supla.fi/audio/3601824

  • app_name: supla
  • media_id: Supla item ID

Optional:

  • is_live: Item is a livestream
'cast_supla_to_my_chromecast':
  alias: "Cast supla to My Chromecast"
  sequence:
    - target:
        entity_id: media_player.my_chromecast
      data:
        media_content_type: cast
        media_content_id: '
          {
            "app_name": "supla",
            "media_id": "3601824"
          }'
      service: media_player.play_media

Plex

To cast media directly from a configured Plex server, set the fields as documented in the Plex integration and prepend the media_content_id with plex://:

'cast_plex_to_chromecast':
  alias: "Cast Plex to Chromecast"
  sequence:
  - service: media_player.play_media
    target:
      entity_id: media_player.chromecast
    data:
      media_content_type: movie
      media_content_id: 'plex://{"library_name": "Movies", "title": "Groundhog Day"}'

Play (almost) any kind of media

Chromecasts can play many kinds of modern media (image/audio/video) formats. As a rule of thumb, if a Chrome browser can play a media file a Chromecast will be able to handle that too.

The media needs to be accessible via HTTP(S). Chromecast devices do not support other protocols like DLNA or playback from an SMB file share.

You can play MP3 streams like net radios, FLAC files or videos from your local network with the media_player.play_media service, as long as the media is accessible via HTTP(S). You need to set the media_content_id to the media URL and media_content_type to a matching content type.

# Play a video file from the local network:
service: media_player.play_media
target:
  entity_id: media_player.chromecast
data:
  media_content_type: "video"
  media_content_id: "http://192.168.0.100/movies/sample-video.mkv"
# Show a jpeg image:
service: media_player.play_media
target:
  entity_id: media_player.chromecast
data:
  media_content_type: "image/jpeg"
  media_content_id: "http://via.placeholder.com/1024x600.jpg/0B6B94/FFFFFF/?text=Hello,%20Home%20Assistant!"

Extra media metadata (for example title, subtitle, artist or album name) can be passed into the service and that will be shown on the Chromecast display. For the possible metadata types and values check Google cast documentation > MediaInformation > metadata field.

# Play a movie from the internet, with extra metadata provided:
service: media_player.play_media
target:
  entity_id: media_player.chromecast
data:
  media_content_type: "video/mp4"
  media_content_id: "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4"
  extra: 
    metadata: 
      metadataType: 1
      title: "Big Buck Bunny"
      subtitle: "By Blender Foundation, Licensed under the Creative Commons Attribution license"
      images:
        - url: "https://peach.blender.org/wp-content/uploads/watchtrailer.gif"
# Play a netradio, with extra metadata provided:
service: media_player.play_media
target:
  entity_id: media_player.chromecast
data:
  media_content_type: "audio/mp3"
  media_content_id: "http://stream.tilos.hu:8000/tilos" 
  extra: 
    metadata: 
      metadataType: 3
      title: "Radio TILOS"
      artist: "LIVE"
      images:
        - url: "https://tilos.hu/images/kockalogo.png"

Cast devices and Home Assistant on different subnets

Cast devices can only be automatically discovered if they are on the same subnet as Home Assistant. Setups with cast devices on a different subnet than Home Assistant are not recommended and not supported. If this is not possible, it’s necessary to either enable mDNS forwarding between the subnets or to provide a list of known hosts.

Home Assistant Container

When running the Home Assistant Container in Docker, make sure it is running with host network mode. Running without it is not supported by the Home Assistant project, and will cause this integration to be unable to discover to your Cast devices.