Maintaining constant casting on Google nest devices

Hi there,

I currently have ten-ish Google Nest devices specifically displays that I have integrated in the house to be the physical display screens for Home Assistant.

This works well overall through the leveraging of casting the various dashboards to the various screens. Node Red automation constantly checks the status of all of these devices every two minutes and as long as the status of the device is playing it takes no action. With various other features for bedroom screens at night, etc.

The problem I have is if the screen is casting and I slide to the left to go back to the hub home page the status of the casting in the background still shows as playing. And the hub never transitions back to the cast screen.

Is there a way to recast or force the device back to the cast screen without reinstating the whole casting procedure. As it creates a transition screen that would not be ideal to be constantly initiated. I really just need a way to determine if the user has left the casting window, but I have found nothing that changes or indicates this.

Does anyone have any ideas?


Yeah it’s pain - and often I find that when HA tries to cast I just get a white screen (or with ‘connecting…’ or various other options).

I found a way of doing it, but it’s not pretty. Basically it involves a script running on the page that reports back to HA every minute that the screen is visible. On the HA side, if the screen has not been visible for the last couple of minutes, cast to it again (as long as it’s still ‘playing’ HA and not Spotify or something else).

I hacked something by editing the code behind another custom component on the dashboard (lovelace-digital-clock). I put the following at the end of “set hass(hass)”:

            setInterval(function() { self.checkVisible(); }, 60000);

And then the code:

    checkVisible() {
        if (!main) {
            main = document.querySelector('home-assistant')
        }'binary_sensor.cast_gh_3_visible', {
            state: (document.hidden ? 'off' : 'on'),
            attributes: {
                friendly_name: 'Cast GH-3 Visible',
                width: main?.offsetWidth,
                top: main?.offsetTop,
                timestamp: new Date(),
                updated: formatTime(new Date(), { ampm: true })

    post(entity, payload) {
        var xhr = new XMLHttpRequest();'POST', ''+entity, true);
        xhr.setRequestHeader('Authorization', 'Bearer mytoken');
        xhr.setRequestHeader('Content-Type', 'application/json; charset=UTF-8');

There are probably many simpler ways of doing it, but this works so I haven’t looked at it further. I’ve seen posts that you can put any code you like in dashboard skins, so that would be cleaner. Maybe I need to make it a proper custom component.