Google Nest Hub as Dashboard with DashCast add-on

What he said was not inappropriate, but calling him a dick is.

Anyways, the original post is missing quotes around the template and any amount of copy/paste/alter will not work.

- condition: template
  value_template: "{{ state_attr('media_player.nesthubmaxf32f', 'app_name') != 'DashCast' }}"

oh! I am sorry if I was missing some quotes. I was probably modifying the config before posting it here, but didn’t really check the validaity of it. Sorry for the confusion. But for what it is worth, below is what I am using now. I added a 20-second delay before the next re-casting if the Nest Hub became unavailable/offline. This is because casting right after Nest Hub boots up usually will fail (even though the state of the media player shows that it is showing the dashboard, it is not.)

  input_boolean:
    study_nest_hub_boot_delay:
      name: Study Nest Hub boot delay
      icon: mdi:television-off

  automation:
    - id: "study_nest_hub_recast"
      alias: "[nesthub] Study Nest Hub recast"
      description: ""
      trigger:
        - platform: state
          entity_id:
            - media_player.study_nest_hub
          to: "off"
      condition: []
      action:
        - choose:
            - conditions:
                - condition: state
                  entity_id: input_boolean.study_nest_hub_boot_delay
                  state: "on"
              sequence:
                - delay: "00:00:20"
                - service: input_boolean.turn_off
                  data: {}
                  target:
                    entity_id: input_boolean.study_nest_hub_boot_delay
        - service: media_player.volume_set
          data:
            volume_level: 0
          target:
            entity_id: "{{ trigger.entity_id }}"
        - service: dash_cast.load_url
          data:
            entity_id: "{{ trigger.entity_id }}"
            url: https://your-url:8123/
            force: true
      mode: single

    - id: "study_nest_hub_offline"
      alias: "[nesthub] Study Nest Hub offline"
      description: ""
      trigger:
        - platform: state
          entity_id:
            - media_player.study_nest_hub
          to: unavailable
      condition: []
      action:
        - service: input_boolean.turn_on
          data: {}
          target:
            entity_id: input_boolean.study_nest_hub_boot_delay
      mode: single

Another issue with this approach is that using DashCast is not an officially supported approach for casting HA dashboards. The officially supported approach is https://cast.home-assistant.io/ or , although I find it more difficult (i.e. more issues to solve) to use than this.

One particular drawback for using unofficially supported approach is that you may find unexpected bugs. Recently I just encountered an issue that when https is used, sensor cards won’t work (Sensor Card doesn't show in Google Nest Hub · Issue #14465 · home-assistant/frontend · GitHub). So if you run into problems, you may want to try https://cast.home-assistant.io/ or Google Cast - Home Assistant.

Hi,

I was following the above mentioned ways to have it work in my home and it continued to fail until
I got my nest_hub out of the group that was setup in the group in google home app.
@chicknlil25 You may want to try that if your nest_hub is included in a group that you have made.

So it works now, but there is something weird happening with the integration.
When I fire dash_cast.load_url, it would turn on dastcast on every nest device in the network.
The dashboard is casted only to nest_hub but dastcast would appear “idle” in every nest device.

So it means that the volume is set to 0 with the above script, to avoid the “boing” sound on
the nest hub but still that prompt sound comes out from other nest devices.
I can script that to set volume to 0 for all the devices on the network, but what is the point to
consider a non-targeted device?
I have 2 other nest mini devices, which is paired as a stereo speaker and those 2 actual and
1 virtual device have all their app_name as dashcast and the state is “idle”.

This won’t happen when I separately use catt to cast the dashboard to the targeted device.

Do you guys have multiple nest devices in the network?

I have 3 Nest Hub actually. This doesn’t happen to me. Maybe you want to check trigger.entity_id in automation trace to see what’s going on? On the other hand, you can try to duplicate the automation for each device and hard-code the entity_id (instead of relying on the trigger object) and see if that fixes your issue.

@chiahsing
Thanks for your suggestions. I will then try to identify the cause on my end.

Update:
I have checked and the script in the beginning would trigger dashcast on other devices but will not
come out with the prompt sound.
But if I put the content of the script in the automation, it would trigger the prompt sound from a untargeted device.
Will check more, but I am kinda clueless of what is happening here.

Just want to share another version of automation using custom component pyscript (GitHub - custom-components/pyscript: Pyscript adds rich Python scripting to HASS). I personally think this is way better than YAML, especially when you have multiple Nest Hubs to cast. To use the following script, you just need to update the first two global variables.

_DASHBOARD_URL = 'http://xxx.xxx.xxx.xxx:8123/'
# The part after 'media_player.'
_NEST_HUBS = ['nest_hub_living_room', 'nest_hub_study']


def nest_hub_trigger_factory(nest_hub):
    entity_id = f'media_player.{nest_hub}'
    avail_state = f'pyscript.{nest_hub}_availability'

    state.persist(avail_state, default_value='1')

    @state_trigger(f'{entity_id} == "off"', state_check_now=True)
    def recast_nest_hub():
        if state.get(avail_state) == '0':
            log.info(f'{entity_id} was unavailable. Wait for 20 secs')
            state.set(avail_state, '1')
            task.sleep(20)
        log.info(f'Recast {entity_id}')
        media_player.volume_set(entity_id=entity_id, volume_level=0)
        dash_cast.load_url(entity_id=entity_id,
                           url=_DASHBOARD_URL, force=True)

    @state_trigger(f'{entity_id} == "unavailable"', state_check_now=True)
    def nest_hub_is_unavailable():
        log.info(f'{entity_id} is unavailable')
        state.set(avail_state, '0')

    return recast_nest_hub, nest_hub_is_unavailable

_triggers = [nest_hub_trigger_factory(nh) for nh in _NEST_HUBS]
2 Likes

@chiahsing

Thanks for the pyscript. I tried and the script works smoothly,
but still dashcast would activate for the untargeted device.
I have 1 nest hub, 2 Chromecast for Google TV and 2 nest mini (which is stereo paired)
So the nest hub that I want to cast the dashboard is only one.

I have found that if I make a group in google home app and include the stereo paired nest mini
in any group, it would activate dashcast on the nest mini and the prompt sound comes out.
If I don’t, only nest hub would activate dashcast.
Chromecast for Google TV will be affected as well if included in the group where nest hub is also in the group.
So getting rid of groups totally, now it all work as expected.
@chiahsing , could you please try to make a group and include 2 of your nest hubs in there?
If you dashcast to one nest hub, my issue is that it would also activate dashcast on the other nest hub.

You may find that it is weird, but that is what I am experiencing, and again casting directly with catt command, no issues at all.

I don’t really trust the grouping in Google Home. It has other issues. But in your case, I think you can also try using catt. It doesn’t really matter how you cast the dashboard. It’s just easier if DashCast integration works for you.

@chiahsing
Yes, maybe in my environment, casting with catt is proven to work already so it might be the best way.
Anyway, I thank you for giving us a head up to this integration.

Update: The weird problems are gone now I believe because of the recent updates of pychromecast. Dashcast integration is working perfectly.

Does anyone get the mini-graph-card wokring with DashCast?

If you are using https, the problem is in workbox/chrome. (Sensor Card doesn't show in Google Nest Hub · Issue #14465 · home-assistant/frontend · GitHub).

1 Like

Any tip to get the dashboard fit the screen ?

Thanks, the script is working great. I have one issue, though: I am using the Nest Hub also as a controller for my Nest Doorbell. If someone rings the doorbell, the image appears briefly and is then immediately replaced by the HA dashboard. Would it be possible to amend the script to either give priority to the Nest Doorbell or, if that is too complicated, just add a certain delay (e.g. 1 minute) before the HA dashboard is recast?

There’s an AppName attribute in the media_player entity. Maybe you can try that.

1 minute delay is certainly very easy to add. Just add task.sleep(60) before dash_cast.load_url().

Thanks a lot! I went with your suggestion but the doorbell video feed is apparently not treated as an app. The attribute keeps showing the most recent app while the feed is on. So I went with the delay, and also commented out the media_player.volume_set to 0 so I can hear the doorbell chime.

Everytime I go to cast, it keeps casting the login screen for HA

You need to configure trusted network because you won’t have the keyboard to type the username and password. And once it is confitured, you tick the “Keep me logged in” box and press the hidden trusted network function under the usernamd and password fields. The option is somtimes hidden due to some CSS issue, but you can still click on it.

I did

homeassistant:
  auth_providers:
    - type: homeassistant
    - type: trusted_networks
      trusted_networks:
        - 192.168.50.217  # my Google Nest Hub IP
      trusted_users:
        192.168.50.217: longuseridnumber

also tried

trusted_users:
  192.168.50.217: <longuseridnumber>

but that caused my HA to restart into safe mode

try this , create a user for your nest hub and paste its id.

homeassistant:
  auth_providers:
    - type: homeassistant
    - type: trusted_networks
      trusted_networks:
        - 192.168.50.0/24 
        - 127.0.0.1
      trusted_users:
        192.168.50.217: # Google Nest Hub user id.