Let me start by saying that my wife and I are huge media consumers. I have an older model Synology NAS (DS214-Play) packed with media and running Plex, and we subscribe to Netflix. We love nothing better after a long week of work than to spend time over the weekend kicking back watching something. And when I’m the only one home, there will typically be a podcast playing in the background throughout the house. So it makes sense that media should play a part in the smart home.

In my opinion, Google’s Cast streaming protocol is hands-down the best you can use right now, especially for the smart home. The Chromecast line of devices provides the highest level of compatibility from Android to Apple, Windows, and Linux. From mobile through to desktop PC, and support for casting video and audio. Not to mention it’s integration with a plethora of devices.

Google Chromecast
Google Chromecast 2

Better again, is that Chromecast/Google Cast is a piece of cake to integrate with Home Assistant, and, comes with native support for Google Assistant/Home. That is why Google Cast capable devices litter my home. Media, delivered to any Google Cast capable room, at any time, and from any device. [Sales pitch off]

Home Assistant media
My Home Assistant Media page

Without getting complicated, Google Cast devices work reasonably well on their own using Google Home/Assistant. Here are some examples of some native functionality.

Both my Sony Android TV and all Chromecasts plugged into non-smart, but HDMI-CEC supported TVs, can turn the TV on and off.

OK Google, turn off the media TV.

The Sony Android TV can directly have the volume changed, while the Chromecasts support software volume.

OK Google, turn the living TV volume up.

Notice in that last example I specified the living room TV. That is because my living room TV’s soundbar also supports Google Cast audio, and can be controlled separately.

OK Google, play Black Sabbath in the living room.

With the addition of a Google Home in the living room, audio only requests play automatically on the soundbar speakers, not the TV. When playing video, such as from YouTube, it automatically plays through the TV.

And finally how about something from Netflix? The subtlety of this request is that the Google Home knows which room it is in, and therefore plays on that room’s default device.

OK Google, play Star Trek Discovery.

Despite the above conveniences, it’s not all smooth sailing. Some integration is lacking between Google Home and Android TV such as not being able to change TV channels, and no Netflix compatibility. Also, media can’t be accessed from Plex media server using voice. The word on the street is that more Android TV / Google Home functionality is on its way, while there is still no word regarding Plex.

But additional benefits (conveniences) can be added through Home Assistant. Not to mention making up for some of the current deficiencies as previously outlined. Let’s take a look at some of these use cases.

Android TV – Show me the news

I arrive home at regular times, coincidentally when numerous nightly news programs are on. Depending on the time within this 1.5 hour period depends on which program I typically watch. Given this is an everyday routine, it makes for a perfect home automation task.

This automation is triggered the moment the home network detects the presence of my mobile phone. That happens the moment I pull the car into the garage.

trigger:
- entity_id: device_tracker.chad
  platform: state
  to: home

Then make a few checks, starting with the day and time. Also, check if the living room TV is already on. If it’s on, then assume that someone may already be watching the TV, so don’t do anything.

condition:
- condition: and
  conditions:
  - after: '18:00:00'
    before: '18:30:00'
    condition: time
    weekday:
    - mon
    - tue
    - wed
    - thu
    - fri
  - condition: state
    entity_id: media_player.living_tv
    state: 'off'

Assuming these conditions pass, then turn the living TV on, wait 3 seconds, then change to the correct channel.

action:
- data:
    entity_id: media_player.living_tv
  service: media_player.turn_on
- delay: 00:00:03
- data:
    entity_id: media_player.living_tv
    source: 9HD Brisbane
  service: media_player.select_source

Here it is in action.

Turn off all the TVs when no one is home

Inversely, when no one is home then turn off all the TVs. The group.occupants entity state of not_home triggers this automation.

trigger:
- entity_id: group.occupants
  platform: state
  to: not_home
action:
- data:
    entity_id: media_player.living_room
  service: media_player.turn_off
- data:
    entity_id: media_player.media_tv
  service: media_player.turn_off

Android TV – Change channels

I previously mentioned that Android TV doesn’t work that well with Google Home. Until this is improved, we can work around these limitations using integrations with Home Assistant. We first saw this in a previous automation where I could change the TV channel based on the time I was home.

In this use case, I want to issue a verbal channel change command through Google Home. That proves particularly useful when the TV remote goes missing, or when the hands are full such as when cooking. Even better is that this functionality is achieved using a Home Assistant scene with just four lines of code (per channel).

- name: Channel 10
  entities:
    media_player.living_tv:
      source: TEN HD

What’s great about using scenes is that they are easily mapped through to Google Home. But Home Assistant’s integration with Google Home is far from perfect, with the commands always coming in the format of turning something on or off. The above example would be ‘Hey Google, turn on channel 10‘.

Broadlink RM Mini
Broadlink RM Mini3

Older TV – Change channels

Older TVs are more challenging and require falling back on traditional technology, like infrared remotes. That is where devices like IR blasters take the place of the remote control. I’m using the Broadlink RM Mini3, which already has Home Assistant support.

My integration is broken down into two parts. Firstly, the IR data for each TV remote control button press is stored, and secondly sending a combination of individual button presses to the TV.

Here is a script for a TV remote control button press, in this case for 0.

media_channel_0:
  alias: Media Channel (0)
  sequence:
  - data:
      packet: JgBwAFIRJxQUExYSKRIXEBQVFhAoFRIUFhEWEhcAA2BSECgTFxIUEisRFhEUExcRJxQUExYSFhEXAANdVBEnFBcRExYoERQUFRIXECoSFhEVExMUFwADXFASKxMWERQTKRQVERQUFhImFRMTFhIUExcADQUAAAAAAAAAAA==
    service: broadlink.send_packet_10_1_1_103

Much like a scene, scripts are also easily integrated with Google Home. In this case, to differentiate a channel change request between the living room TV and the media room, the media room TV command includes the room name, ‘OK Google, turn on media channel 10‘.

For turning on ‘channel 10’ a script sends multiple commands via the IR blaster to the TV; media_channel_0, media_channel_1, media_channel_0.

media_channel_ten:
  alias: Media Channel 10
  sequence:
  - data:
      entity_id: device_tracker.rmmini3_media
      service: script.media_channel_0
  - data:
      entity_id: device_tracker.rmmini3_media
      service: script.media_channel_1
  - data:
      entity_id: device_tracker.rmmini3_media
      service: script.media_channel_0
Chad is a consultant to the AEC industry, a design technologist, VDC advocate, BIM Manager, early Revit adopter, and public speaker.