Using CATT

I do the same using an input Boolean and a big ssh node to run Catt. I’m not at my PC at the moment but it basically shows a Lovelace view whenever I toggle the input Boolean or ask google to show a certain screen.

This is for Raspberry, how can i use linux commands from Hassio?

I’m interested to sée the code when you have Time for Share :slight_smile: thank you

You Can use those commands by ssh.directly on ha

From where do you do that?

Hope this helps?

[{"id":"d170f2cc.40761","type":"server-state-changed","z":"d1f81840.ef9ad8","name":"Cast Input Boolean","server":"82dafd4c.4d3b4","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"input_boolean.kitchen_catt","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"on","halt_if_type":"str","halt_if_compare":"is","outputs":2,"output_only_on_state_change":true,"x":130,"y":1580,"wires":[["2ae893d7.d125cc","b34488de.909988"],[]]},{"id":"2ae893d7.d125cc","type":"stoptimer","z":"d1f81840.ef9ad8","duration":"1","units":"Minute","payloadtype":"num","payloadval":"0","name":"","x":360,"y":1620,"wires":[["b83d1f04.aef15","10e606e6.93b5a9"],[]]},{"id":"b34488de.909988","type":"bigssh","z":"d1f81840.ef9ad8","name":"Cast System Info","commandLine":"/home/matt/.local/bin/catt -d 'Kitchen Display' cast_site \"http://192.168.68.110:61208\"","commandArgs":"","minError":1,"minWarning":1,"noStdin":false,"format":"","payloadIsArg":false,"myssh":"6a7f26ce.981ca8","x":550,"y":1460,"wires":[[],[],[]]},{"id":"b83d1f04.aef15","type":"api-call-service","z":"d1f81840.ef9ad8","name":"Reset Cast Switch","server":"82dafd4c.4d3b4","version":1,"debugenabled":false,"service_domain":"input_boolean","service":"turn_off","entityId":"input_boolean.kitchen_catt","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":550,"y":1560,"wires":[[]]},{"id":"10e606e6.93b5a9","type":"bigssh","z":"d1f81840.ef9ad8","name":"Stop Cast","commandLine":"/home/matt/.local/bin/catt -d 'Kitchen Display' stop","commandArgs":"","minError":1,"minWarning":1,"noStdin":false,"format":"","payloadIsArg":false,"myssh":"6a7f26ce.981ca8","x":540,"y":1660,"wires":[[],[],[]]},{"id":"82dafd4c.4d3b4","type":"server","z":"","name":"Home Assistant","legacy":false,"addon":false,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true},{"id":"6a7f26ce.981ca8","type":"SSH_Credentials","z":"","host":"192.168.68.110","port":"228","userlabel":"[email protected]"}]

1 Like

Great!! thank you very much it seem to works !

Did you manage to get your scenario/situation working? Mine is the same.

I have a similar issue and want to achieve the same as you did. But your description is a little over my head. Maybe you can dumb it down a bit and step it out a little for me?

I’ve set up as per John post, and I can cast if “I disable the SSL certs for my Home Assistance instance to allow straight http traffic”. I’m using DuckDNS addon.

Cheers.

I have a node-red automation to cast the display every 9:59 mintuten, because I thought that every 10 min the cast is ended. Is this still a issue?

yes, i’ve forwarded only the 443 port internally to hassio , then i’ve installed the addon: NGINX Home Assistant SSL proxy

1 Like

No worries, I’ll try break it down a bit more. Guess I should flag what I was looking to achieve:

  1. Get CATT working, obviously
  2. Have SSL enabled internally, just because…
  3. Ideally have a free certificate (LetsEncrypt or OpenSSL) without needing to make my system externally accessible to do this (didn’t want to open up port 80 or 443 to generate the lets encrypt certs)

With that in mind, I’ve done the following:

  1. Install the Let’s Encrypt addon in HASSIO.
  2. Registered a domain name. I’m using Google Domains but anything should do. You could probably simplify this process by reviewing the documentation for Lets Encrypt and picking a domain provider that’s included in the list of providers that support “DNS Challenge”. Google Domains isn’t one, but I have other domains with Google and want to keep them together (Note Google Domains is different from the “Google” option in the Lets Encrypt doco, which would require a paid subscription to use the APIs).
  3. Set up a free CloudFlare account if you haven’t already got one and then log in to https://dash.cloudflare.com/
  4. From the home tab in CloudFlare, click ‘Add A Site’. Add the domain name from step 2. Choose the free plan. A scan will be done for DNS Settings. Once that’s complete follow the on screen instructions to update the DNS Name Server settings at the site where you purchased your domain name to the values that CloudFlare tells you to.
  5. Wait for confirmation that the CloudFlare DNS registration is complete. They say it may be a day but it took me closer to 10 minutes, it wasn’t very long.
  6. Return to the home page of your CloudFlare account and the site you added above will be there. Click it.
  7. On the page that loads, in the right hand pane there is a section with some API settings. Select ‘Get your API token’. Create a new API token with two Permissions of Zone-Zone-Read and Zone-DNS-Edit. The ‘Zone Resources’ should be ‘All Zones from an account’ with your account selected. I found these settings in the ‘Lets Encrypt’ Documentation that’s available in HASSIO following the install in step 1, so feel free to verify. Make sure you note your API token as I’m not sure you can retrieve it again, although you can generate a new token by repeating this.
  8. Still in Cloudflare return back to your Dashboard and again open your site. This time at the top go to the ‘DNS tab’. Click ‘Add Record’ of type ‘A’ and type in a subdomain name (“something”.your-domain.com). Only include the subdomain name, not the full URL. Set the IP address to your local networks IP for your HA instance. In my case that was 10.0.0.10. Click the cloud icon near the submit button so the Proxy Status changes to DNS only and click save. Having done this, browsing to SOMETHING.your-domain.com will now take you to your HA instance if you are on your personal network, as the sub domain will resolve to your internal IP. (I should add, HA should have a static IP on your network).
  1. Return to HASSIO and configure the Lets Encrypt Addon. You’ll need an email address, domains (subdomain you configured above, or if you want you can use a wildcard *.your-domain.com) and to set the challenge to “DNS”. Provider is “dns-cloudflare” and Cloudflare_api_token the value generated in step 8. Refer to the addons doco for formatting. Also make sure the certificate and private keys match those that Home Assistant are set to use.
  2. Save the LetsEncrypt config and start the addon (backup any existing SSL keys first but!). If all is good at this point it will generate you a new key pair that will be dropped on your HASSIO’s /ssl/ folder. This will be a key generated from an externally trusted source (Lets Encrypt) but the IP address that it resolves to will be one that’s on your own network.
  3. Make sure your HASSIO instance has the ‘internal url’ set to use https, and that your configuration.yaml file has the certs configured.
  4. In your configuration.yaml file configure ‘authproviders’, you’ll want to include the ‘homeassistant’ provider as well as the ‘trusted_networks’. If you don’t add ‘homeassistant’ then you lose your standard authentication. Under trusted networks include trusted_networks entry with the IP address of your Home Hub. I gave it a /32 address so the only device trusted was the specific address rather than a range. Set a trusted user, which I think is documented elsewhere here otherwise check the Home Assistant doco. Set Allow_Bypass_Login to true
  5. Restart Home Assistant, remembering to change to https://sundomain.your-domain.com/

By now you should have a trusted cert pointing to your home assistant instance for any devices that are on your local network. You also wouldn’t have had to touch your router to do port forwarding or anything. Start up CATT and try casting to your address, typing the full domain rather than the IP and including https://. With any luck it’ll work and from there you can play about with automations and the like.

A lot of the above may be fairly specific to me. You don’t have to pick CloudFlare to do your DNS for example. If you are happy to open up port 80 and 443 to generate the certs, you could skip half of the above and do that instead. You could use 'DNS Challenge" but use someone other than Cloudflare.If using Lets Encrypt then you’ll want to look at automating re-generation of licenses etc.

The caveat is I have seen this break the querying of calendar data stored in HASSIO from the Google Hub only (and this isn’t addon specific, but rather globally), and I’m not sure what else may or may not be broken. Everything else in my views currently functions however.

Regarding step 8, that’s needed to resolve the hostname due to the Google Home Hub bypassing your routers DNS and going straight to Googles which has no concept of your internal address. You can skip step 8 and instead put in a firewall rule to block the Home Hub using Google DNS (addresses 8.8.8.8 and 8.8.4.4) which will cause it to fail back to your own networks DNS. May or may not need a rule at your local network to redirect the URL to your IP. I tested this approach briefly and it worked, but didn’t stick with it.

Lastly, I used a subdomain, but you don’t have to. The reason I did is I can use steps 8-10 to also generate certs for other devices on my network with each device having its own subdomain. If you have a single device you want to assign certs to, then that may not be worthwhile.

I hope I haven’t missed too much. Intentionally skimmed over the CATT bit as I think others have covered that. Happy to try answer any questions. I’m not overly proficient in these matters, above is me just joining dots and brute forcing my way at points. Apart from not having a calendar currently, I’m fairly happy with how its working.

4 Likes

Thanks for taking the time to explain this and write out the detail. It lead me to a solution for my setup with duckdns addon after a few hours of fiddling.

The main thing was to map a new domain to my local hassio ip (as I had most of the other steps already in place)

1 Like

Nice… Working! Was stuggling with getting my commands working, but this does the job!

1 Like

Catt seems to play well with the Browser_mod media player and the Google Assistant Webserver. For example, you can cast your lovelace frontend to your Google hub, then play a seperate audio with Browser mod. Then you can send audio notifications (broadcasts) to the hub and it won’t interupt the music playing. In fact you can set your hub to show the broadcast text on the screen.

1 Like

Okay I have a problem, I installed Catt and after running the command I get an error:
Running HA on a pi.

Could some one told me what’s wrong?

Traceback (most recent call last):
  File "/usr/bin/catt", line 10, in <module>
    sys.exit(main())
  File "/usr/lib/python3.8/site-packages/catt/cli.py", line 570, in main
    return cli(obj={}, default_map=get_default_map())
  File "/usr/lib/python3.8/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/usr/lib/python3.8/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/usr/lib/python3.8/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/lib/python3.8/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/lib/python3.8/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/usr/lib/python3.8/site-packages/click/decorators.py", line 33, in new_func
    return f(get_current_context().obj, *args, **kwargs)
  File "/usr/lib/python3.8/site-packages/catt/cli.py", line 235, in cast_site
    cst = setup_cast(settings["device"], controller="dashcast", action="load_url", prep="app")
  File "/usr/lib/python3.8/site-packages/catt/controllers.py", line 144, in setup_cast
    cast, cc_info = get_cast(device_name)
  File "/usr/lib/python3.8/site-packages/catt/controllers.py", line 92, in get_cast
    cache = Cache()
  File "/usr/lib/python3.8/site-packages/catt/controllers.py", line 222, in __init__
    devices = get_chromecasts()
  File "/usr/lib/python3.8/site-packages/catt/controllers.py", line 45, in get_chromecasts
    devices.sort(key=lambda cc: cc.name)
AttributeError: 'tuple' object has no attribute 'sort'

Sorry to reply on an old post but does your google home make the alert noise every 10 minutes or is there a way to disable as could see that getting a bit annoying?

(see this link for install instructions)

yes, i was also getting the beep every 10 minutes, to solve it, i created this in the cast.sh file that I now use:

if ! catt -d "Living Room display" status | grep 'PLAYING'; then 
    catt -d "Living Room display" volume 0
    catt -d "Living Room display" cast_site http://192.168.178.87:8123/lovelace-test/0
fi

It checks if anything is playing, then it wont cast. If nothing is playing, it turns the volume off and casts the screen. I just leave the volume off. Whenever I say “ok google” the volume goes back on anyway. you could turn the volume back on after the cast, but that also makes a sound.

The automation I use to cast the cast.sh file is:

- id: '1589529246400'
  alias: CastToHub
  description: ''
  trigger:
  - minutes: /10
    platform: time_pattern
  condition:
  - after: '5:00'
    before: '23:30'
    condition: time
  action:
  - data:
      addon: a0d7b954_ssh
      input: bash /config/cast.sh
    service: hassio.addon_stdin
5 Likes

Can you also give “the command” that you mention?

Yes sure. The command is:
catt -d “Google Cast” cast_site ‘https://name.duckdns.org:8123/lovelace-hub/begin-hub

Tried alsof without the port number.