Stream your floor plan, dashboards to Nest Hub, ChromeCast… using catt with HA, HassOS…
Hi,
It took me some time to figure this out, so maybe helpful for others also…
There are two options that I could find to do this?
So here it goes, first we need to configure something to logon on a device without a keyboard, like a Google Nest hub for instance;
To do this we need to add something to the configuration.yaml file, trusted networks, trusted users
So basically you add your ChromeCast devices as a trusted network and define a user that can login without entering credentials
For this we need to add auth_providers to our configuration.yaml
(https://www.home-assistant.io/docs/authentication/providers/#trusted-networks)
- trusted_networks
- trusted users
Add a device to the trusted network
auth_providers:
- type: trusted_networks
trusted_networks:
- 192.168.0.154/32
- 192.168.0.165/32
Now we also need to add a trusted user who can access the dashboard
That we do true the option: trusted_users and adding the option to bypass the login true credentials
trusted_users:
192.168.0.154: ID OF THE USER
192.168.0.165: ID OF THE USER
allow_bypass_login: true
you find the ID of the user, not the name by going to your HA settings, users, click on a user and on the top of the window you can see the ID of that user, copy this and put it in your config.
Important: if you use Nabu Casa you also need to add this option (type: homeassistant) under auth_providers because otherwise every connection will be untrusted because Nabu Casa is not forwarding the IP address of the incoming request at this moment;
See the post about this here: https://www.nabucasa.com/config/remote/
Luckily this can easily fixed by adding this under authenticated providers
auth_providers:
- type: homeassistant
Personally I wanted to restrict things as much as possible so I only allowed the 2 Hubs I have to be considered to be on a trusted network and restricted the user to a special “hub” account I created in HASS. So my configuration.yaml looks like this:
auth_providers:
- type: homeassistant
- type: trusted_networks
trusted_networks:
- 192.168.0.154/32
- 192.168.0.165/32
trusted_users:
192.168.0.154: 6r18ewef97534332dwhihfwif30fbd1bd
192.168.0.165: 6r18ewef97534332dwhihfwif30fbd1bd
allow_bypass_login: true
So now that we have done the preparations we can start configuring the casting option
- the build in Cast service of HA, (https://www.home-assistant.io/blog/2019/08/06/home-assistant-cast/) works but you need to expose your HA installation with SSL to the outside world using Nabu Casa (payed service) or DuckDNS or something like this.
it worked for me but in my short tests it was not always handling custom cards correct and also was not that reliable to be honest, so I’m not going further is this here now.
So as always some smart developer had probably the same issues and found a solution for this https://github.com/skorokithakis/catt
Basically you can cast almost anything with this, but it took some time for me as a non developer, wizard to figure it out but now that I have it working, I can maybe also help other users with this?
There are two different ways to do this that I could find?
If you install catt in your HassOS installation, it will work but every time you start your HassOS you need to do this again because the docker container is emptied again, not fun and to be honest not workable in my opinion.
So the option you have here is install Catt on another device, Rpi, VM, separate docker container, … or whatever, this works fine but there are some caveats of course, when is this not the case
So for instance install Catt on a raspberry Pi, wel that’s easy as Pi to be honest
Just open a terminal and put in this command
pip3 install catt
After this do a scan to find your cast enabled devices, and it will give a list of all your devices you can use with this service
catt scan
After this you can start casting almost everything to your devices from this machine based on a simple command structure, for instance stream www.google.com to a Nest Hub;
catt -d "NAME OR IP_OF_DEVICE" cast_site https://www.google.com
Here is the complete list of commands for Catt that I could find?
Commands:
add Add a video to the queue (YouTube only).
cast Send a video to a Chromecast for playing.
cast_site Cast any website to a Chromecast.
clear Clear the queue (YouTube only).
del_alias Delete the alias name of the selected device.
del_default Delete the default device.
ffwd Fastforward a video by TIME duration.
info Show complete information about the currently-playing video.
pause Pause a video.
play Resume a video after it has been paused.
play_toggle Toggle between playing and paused state.
remove Remove a video from the queue (YouTube only).
restore Return Chromecast to saved state.
rewind Rewind a video by TIME duration.
save Save the current state of the Chromecast for later use.
scan Scan the local network and show all Chromecasts and their IPs.
seek Seek the video to TIME position.
set_alias Set an alias name for the selected device.
set_default Set the selected device as default.
skip Skip to end of content.
status Show some information about the currently-playing video.
stop Stop playing.
volume Set the volume to LVL [0-100].
volumedown Turn down volume by a DELTA increment.
volumeup Turn up volume by a DELTA increment.
write_config Please use "set_default".
This all works fine, but we off course want to use a device, automation in HA to trigger this;
So we need to find a option to get a way to execute a command on a external machine;
There are maybe other ways to accomplish this? but I could only find the option to do this with ssh,
-
As always this is not working out of the box and we need to do some things before we can use this, what’s new
-
First we need a way to authenticate the connection to the external machine from in HA, you can off course use no password for your ssh connection (Don’t do this!) a better way to do this is using ssh keys, I don’t want to go to far in this in this message:
-
but here you can find a tutorial to do this: https://www.youtube.com/watch?v=b6lJnqeHHns&feature=emb_logo
So now that we have this working, you still need to find a solution to use this in HA, also I don’t know if this is the only option but what I could find was using a shell command for this: https://www.home-assistant.io/integrations/shell_command/
a small example that worked for me;
shell_command:
start_ha_hub_woonkamer: ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i /config/ssh/id_rsa [email protected] catt -d 192.168.0.164 cast_site http://192.168.0.250:8123
After creating the shell scripts in your config and you rebooted HA you can use this shell command in an automation, script… in your HA installation like this for instance
- id: '1591458950260'
alias: test hub
description: ''
trigger: []
condition: []
action:
- service: shell_command.start_ha_hub_woonkamer
This works all fine, no issues here, but it takes some time, efforts to get it all (keep) working and you need to have a seperate device and also when you have a lot of devices, dashboards you need to create shell scripts for everything you want to cast, in my opinion also not the best solution, but it works so it’s an option for who wants to do it this way.
- The second way that I could find, makes things a lot easier and seems to work fine for more then a week now…
Just install this add-on true the add-on store of HassOS: https://github.com/hassio-addons/addon-ssh managed, maintained by the team itself (frenck) so save to say that is a save and good option also to the future.
After this putt this in the config of the add-on
init_commands:
- python3 -m pip install catt
Basically this installs Catt again in your docker after rebooting your machine, HassOS…
Because now that Catt is basically running in HassOS you can use just a simple automation, script to initiate the cast based on a device, time, or whatever you want to use…
Small example that initiates a cast to my Hub based on a movement sensor
- id: '1592380285643'
alias: beweging cast
description: ''
trigger:
- device_id: cb70e3d37b0e492abacd36fc6b6549f4
domain: binary_sensor
entity_id: binary_sensor.beweging_bureau_motion
platform: device
type: motion
condition: []
action:
- data:
addon: a0d7b954_ssh
input: 'catt -d 192.168.0.165 cast_site http://192.168.0.9:8123/lovelace/test'
service: hassio.addon_stdin
Note: The first time you cast something to your Hub for instance you will be greeted with the login screen of your HA installation, if you did everything correct as described above in configuring trusted networks, users you should see an option under the login prompt to click on trusted networks after you do this you will be logged in HA and go to the dashboard you requested.
The first time I tried this I did not saw the option, but this was because I was using a dark theme, but just click on the bottom and it should work fine, if you want to be sure just put your HA on the default lite theme and you will see the option clearly in the logon window.
So hopefully it’s helpful for somebody and off course if you have a better solution don’t hesitate to share this, always willing to lean and share!
source that started this journey https://blog.fuzzymistborn.com/homeassistant-and-catt-cast-all-the-things/
Update I got request of this so small update: yes if you have a Homey and installed the Google ChromeCast app, you can directly cast pages, dashboards… from a Homey flow, no need to use Cast for this, to use this you only have to configure the trusted networks, users part in your configuration in HA.