Skip to content

Using Home Assistant on your Google Hub

Sean edited this page Apr 4, 2023 · 3 revisions

Someone of you may be like me and once you actually saw just how much the Google Hub could do, you were left pretty disappointed in just how much it couldn't do. Thankfully there is no shortage of brilliant and creative people in the HA community. It's actually very easy to get this going and here are the steps taken below.

First, big thanks to this thread for the inspiration and guidance.

Second, you will need the following custom components from HACS:

Once those are installed, you will also need your user ID which you can learn how to get from here.

Lastly, your Google Hub will need a static IP address which you can learn how to do via Google.

You will need to add the following to your configuraion.yaml

homeassistant:
  auth_providers:
    - type: homeassistant
    - type: trusted_networks
      trusted_networks:
        - 192.168.1.x  # my Google Nest Hub IP
      trusted_users:
        - 192.168.1.x: <YOUR USER ID> 
      allow_bypass_login: true

This is the script I use in my scripts.yaml. We sometimes listen to Spotify but was impossible if casting the dashboard to the Hub. You will notice the URL has ?kiosk at the end. Without it, the dashboard would show the header and sidebar, wasting precious space.

cast_ha_nesthub:
  sequence:
    - choose:
        - conditions:
            - condition: template
              value_template: "{{ state_attr('media_player.nesthub', 'app_name') != 'DashCast' }}"
            - condition: template
              value_template: "{{ state_attr('media_player.nesthub', 'app_name') != 'Spotify' }}"
          sequence:
            - service: media_player.volume_set
              data:
                volume_level: 0.0
              target:
                entity_id: media_player.nesthub
            - service: dash_cast.load_url
              data:
                entity_id: media_player.nesthub
                url: http://192.168.1.x:8123/dashboard-hub/0?kiosk
                force: true
            - delay:
                seconds: 5
            - service: media_player.volume_set
              data:
                volume_level: 0.6
              target:
                  entity_id: media_player.nesthub

And finally I use this automation to ensure that if no music is playing, the dashboard is automatically casted to the Hub. The delay is there to allow the changeover to Spotify or a different app of your choice. Without it, DashCast would instantly take back over.

- alias: Recast Dashboard
  initial_state: on
  trigger:
    - platform: time_pattern
      minutes: "/1"
    - platform: template
      value_template: "{{ state_attr('media_player.nesthub', 'app_name') != 'DashCast' }}"
  condition: 
    - condition: template
      value_template: "{{ state_attr('media_player.nesthub', 'app_name') != 'Spotify' }}"
    - condition: template
      value_template: "{{ state_attr('media_player.nesthub', 'app_name') != 'DashCast' }}"
  action:
    - delay:
        seconds: 5
    - service: script.cast_ha_nesthub

While casting to the hub, the screen will never dim or turn off. Because I don't want this to be always on all the time, I have set up another automation that will stop casting under certain conditions like when watching movie, going to bed, or leaving the house. This isn't mandatory, but I think it's useful.

- alias: Turn off Dashboard Cast
  initial_state: on
  trigger:
    - platform: state
      entity_id: media_player.plex_living_room_tv
      to: playing
    - platform: state
      entity_id: media_player.nvidia_shield_pro
      to: playing
    - platform: state
      entity_id: group.family
      to: not_home
    - platform: state
      entity_id: input_boolean.bedtime_sean
      to: "on"
    - platform: state
      entity_id: input_boolean.bedtime_emily
      to: "on"
  action:
    - service: media_player.turn_off
      data:
        entity_id: media_player.nesthub