Python system service to continuously cast Home Assistant to a Google Chromecast device
If you would prefer this functionality as an integration that runs on your HA instance, find this here, The guide below requires an external Linux box.
Home Assistant Cast (HA-Pi-Cast) will continuously cast your Home Assistant dashboard to your Google Chromecast device; only if there is no media playing (or HA is already being casted) and the local time is between the defined "allowed casting time" to save some power overnight.
I'm using this myself for 3 different chromecast devices: Lenovo Smart Display 8 & two 1st Gen Google Nest Hubs.
The project uses CATT (cast all the things) to cast the dashboard to your Chromecast compatible device. Home Assistant does offer an in-built casting option but I found this to be unreliable for me and I couldn't get it working properly without paying for a Nabu Casu subscription... Instead, I wanted to host HA externally myself for free. (well, $1 p/year). The guide I used is here and I bought a domain for $1 from here.
HA-Cast is intended to be ran as a system service on a Linux box. I'm running it on a Raspberry Pi Zero, but any Linux box should do. This service will then iterate over your devices defined inside the config.yaml file every 10 seconds checking the 'status' of each device. We check the status using CATT and will only cast the dashboard if no media is playing or the dashboard is already being casted. This means that any spotify/youtube sessions won't be interupted, and when you end the "playing" session with "Hey Google, Stop" the dashboard will return.
sudo git clone https://github.com/b0mbays/ha-cast.git /opt/ha-cast
sudo nano /opt/ha-cast/config.yaml
sudo bash /opt/ha-cast/setup.sh
Your devices should now start displaying your HA Dashboards!
If you try to play Spotify/Youtube the dashboard will be hidden and will only return after a "Hey Google, Stop" (This may take up to 30 seconds depending how many devices you have)
The service will by default continuously try to cast to your chromecast devices between 06.30am -> 02.00am. (There will also be a 5 minute pause at 23.59pm). You can change these timings yourself if you like inside the ha-cast.py file on line 70.
You can setup your Google Chromecast Compatible devices inside the config.yaml under device_map. There's an example in there too.
The default is set to 10 seconds for checking each device, you can change this inside the config.yaml under cast_delay.
cast_delay: 10
device_map:
"<YOUR_DISPLAY_NAME>": "YOUR_DASHBOARD_URL"
"<YOUR_DISPLAY_NAME>": "YOUR_DASHBOARD_URL"
"<YOUR_DISPLAY_NAME>": "YOUR_DASHBOARD_URL"
# eg: "Office display": "http://192.168.12.104:8123/office-dashboard/default_view?kiosk"
# eg: "Kitchen display": "http://192.168.12.104:8123/kitchen-dashboard/default_view?kiosk"
There is a log file: /opt/hacast/ha-cast.log that you can check for any errors that may occur.
cat /opt/ha-cast/ha-cast.log
Check the system status of the service with:
sudo systemctl status hacast
Restart the service:
sudo systemctl restart hacast
Disable the service on boot:
sudo systemctl disable hacast
Enable the service on boot:
sudo systemctl enable hacast