DewGew said the following:
You don't have to use catt.
I fully understand that DewGew promotes his solution. I have read it, and it depends on what you try to achieve, whether it is useful. It offers possibilities. Fortunately we have often more options to reach our goal.
I think catt is a very nice and simple solution to cast movies, pictures and, in our case, web pages to the Google Nest Hub.
It is simple to install (pip3 install cat) and you can run a web page with "catt cast_site
https://www.website.com".
To cast these things to the Google Nest Hub is beyond Googles intentions, but works nice.
The disadvantage is that you have to send a command from the command line. That means that you have to open on another device a shell and type the command. This is not, what we want. Actually we want, that we say: "Hey (or OK) Google, Domoticz Dashboard on" and that then the Domoticz Dashboard page is shown. DewGew also suggested that your security camera's can be shown. But, if you can access your stream by your browser, you can cast your stream from the security camera to your Google Nest Hub.
My first idea was to create a virtual switch, which would activate a script and that would issue the cast command. At the same time, it would have been possible to activate that switch with a remote command from MQTT.
It did not work, because of the rights Domoticz scripts use. See:
https://www.domoticz.com/forum/viewtopi ... 07#p231907
My Domoticz and catt run on a Raspberry Pi and the MQTT server and Node Red run on a different Pi. The challenge is to get a command from the second RPi, from Node Red (running NORA) to the first RPi, which has catt installed.
I found an excellent piece of software, which does exactly what I need and even more. It is a nice companion for Domoticz, Node Red and MQTT.
The program is called mqtt-launcher. It is created by J P Mens and it is available on github:
https://github.com/jpmens/mqtt-launcher.
Install it on the same hardware as catt has been installed.
As catt installs in the directory ~/.local/bin, I decided to install it in ~/.local/mqtt-launcher.
Install it with: cd .local and git clone
https://github.com/jpmens/mqtt-launcher.
As the display of the Google Nest Hub is only 7", the web page of Domoticz is not very big and it is not easy to tab the different pages.
(Or my fingers are too big

) I decided to make a voice command for each of the different pages. As I use the "Floorplans" on my "Dashboard", I have created 6 pages:
- Floorplans
- LightSwitches
- Scenes
- Temperature
- Weather
- Utility
- Dashboard (is optional as it is identical to Floorplans, but disabled in my flow)
As I own also 5 Camera's, with can be accessed by http://<IP Adress>/video.cgi, I have included these as well.
Configuration:
First you have to create a config file for mqtt-launcher. See the example launcher.conf.example file.
It is possible to insert the command directly in the conf file, but I had some difficulties in sorting out, what is the command and what are the arguments. To be more flexible and to be able to give multiple commands, I decided to use a script file. This makes it also possible to use some kind of logging.
So the launcher.conf points to a local script file, which contains the catt command.
Find below the launcher.conf file:
Code: Select all
logfile = '/home/pi/mqtt_launcher.log'
mqtt_broker = '192.168.xx.yy # default: 'localhost'. If using TLS, this must be set to the domain name signed by your TLS certificate.
mqtt_port = 1883 # default: 1883
mqtt_clientid = 'mqtt-launcher-1'
mqtt_username = 'your name'
mqtt_password = 'your password'
mqtt_tls = None # default: No TLS
topiclist = {
# topic payload value program & arguments
"domoticz/dashboard": {
'on' : [ '/home/pi/.local/domoticz_Dashboard2nest_hub.sh' ],
'off' : [ '/home/pi/.local/domoticz2nest_hub_stop.sh' ],
},
"domoticz/floorplans": {
'on' : [ '/home/pi/.local/domoticz_Floorplans2nest_hub.sh' ],
'off' : [ '/home/pi/.local/domoticz2nest_hub_stop.sh' ],
},
"domoticz/lightswitches": {
'on' : [ '/home/pi/.local/domoticz_LightSwitches2nest_hub.sh' ],
'off' : [ '/home/pi/.local/domoticz2nest_hub_stop.sh' ],
},
"domoticz/scenes": {
'on' : [ '/home/pi/.local/domoticz_Scenes2nest_hub.sh' ],
'off' : [ '/home/pi/.local/domoticz2nest_hub_stop.sh' ],
},
"domoticz/temperature": {
'on' : [ '/home/pi/.local/domoticz_Temperature2nest_hub.sh' ],
'off' : [ '/home/pi/.local/domoticz2nest_hub_stop.sh' ],
},
"domoticz/weather": {
'on' : [ '/home/pi/.local/domoticz_Weather2nest_hub.sh' ],
'off' : [ '/home/pi/.local/domoticz2nest_hub_stop.sh' ],
},
"domoticz/utility": {
'on' : [ '/home/pi/.local/domoticz_Utility2nest_hub.sh' ],
'off' : [ '/home/pi/.local/domoticz2nest_hub_stop.sh' ],
},
"camera/1": {
'on' : [ '/home/pi/.local/camera1-nest_hub.sh' ],
'off' : [ '/home/pi/.local/domoticz2nest_hub_stop.sh' ],
},
"camera/2": {
'on' : [ '/home/pi/.local/camera2-nest_hub.sh' ],
'off' : [ '/home/pi/.local/domoticz2nest_hub_stop.sh' ],
},
"camera/3": {
'on' : [ '/home/pi/.local/camera3-nest_hub.sh' ],
'off' : [ '/home/pi/.local/domoticz2nest_hub_stop.sh' ],
},
"camera/4": {
'on' : [ '/home/pi/.local/camera4-nest_hub.sh' ],
'off' : [ '/home/pi/.local/domoticz2nest_hub_stop.sh' ],
},
"camera/5": {
'on' : [ '/home/pi/.local/camera5-nest_hub.sh' ],
'off' : [ '/home/pi/.local/domoticz2nest_hub_stop.sh' ],
As you can see: I have created for each MQTT command a topic (e.g. domoticz/dashboard), a payload to activate the cast (on) and to deactivate the cast (off) and the script to execute (e.g. /home/pi/.local/domoticz_Dashboard2nest_hub.sh).
As an example find below the example of the domoticz_Dashboard2nest_hub.sh.
Code: Select all
#!/bin/sh
/home/pi/.local/bin/catt cast_site http://192.168.10.50:8080/#/Dashboard >/dev/null &
Create your files for all configured commands and make them executable: chmod +x <filename>.
Result:
Code: Select all
pi@RPi2:~/.local $ ls -l
total 72
drwxr-xr-x 2 pi pi 4096 Dec 27 19:56 bin
-rwxr-xr-x 1 pi pi 91 Dec 28 18:09 camera1-nest_hub.sh
-rwxr-xr-x 1 pi pi 91 Dec 28 18:11 camera2-nest_hub.sh
-rwxr-xr-x 1 pi pi 91 Dec 28 18:12 camera3-nest_hub.sh
-rwxr-xr-x 1 pi pi 91 Dec 28 18:12 camera4-nest_hub.sh
-rwxr-xr-x 1 pi pi 91 Dec 28 18:13 camera5-nest_hub.sh
-rwxr-xr-x 1 pi pi 56 Dec 27 18:33 domoticz2nest_hub_stop.sh
-rwxr-xr-x 1 pi pi 98 Jan 1 14:13 domoticz_Dashboard2nest_hub.sh
-rwxr-xr-x 1 pi pi 99 Dec 27 16:56 domoticz_Floorplans2nest_hub.sh
-rwxr-xr-x 1 pi pi 102 Dec 28 16:40 domoticz_LightSwitches2nest_hub.sh
-rwxr-xr-x 1 pi pi 95 Dec 27 18:38 domoticz_Scenes2nest_hub.sh
-rwxr-xr-x 1 pi pi 100 Dec 27 18:40 domoticz_Temperature2nest_hub.sh
-rwxr-xr-x 1 pi pi 96 Dec 27 18:41 domoticz_Utility2nest_hub.sh
-rwxr-xr-x 1 pi pi 96 Dec 27 18:43 domoticz_Weather2nest_hub.sh
drwxr-xr-x 4 pi pi 4096 Dec 23 12:22 etc
drwx------ 4 pi pi 4096 Sep 2 12:07 lib
drwxr-xr-x 3 pi pi 4096 Jan 4 21:46 mqtt-launcher
drwxr-xr-x 4 pi pi 4096 Dec 23 12:22 share
I created also a script to stop the casting: domoticz2nest_hub_stop.sh.
Contents:
Code: Select all
#!/bin/sh
/home/pi/.local/bin/catt stop >/dev/null &
Run /home/pi/.local/mqtt-launcher/mqtt-launcher.py &
Test your commands to start the casting of your web pages.
If you are satisfied you may kill mqtt-launcher.py.
In order to start this python script also after a reboot you may want to run it as a service (daemon).
To do so, create a file mqtt-launcher.service, with the following contents:
Code: Select all
[Unit]
Description=MQTT launcher
After = network-online.target
[Service]
Type=simple
WorkingDirectory=/home/pi/.local/mqtt-launcher
ExecStart=/usr/bin/python /home/pi/.local/mqtt-launcher/mqtt-launcher.py
Restart=always
RestartSec=1
User=pi
Group=pi
[Install]
WantedBy=multi-user.target
Copy this file to: /etc/systemd/system as follows:
sudo cp /home/pi/.local/mqtt-launcher/mqtt-launcher.service /etc/systemd/system
sudo systemctl start mqtt-launcher
If everything works fine you can enable it: sudo systemctl enable mqtt-launcher
You can stop the service with sudo systemctl stop mqtt-launcher and disable it with sudo systemctl disable mqtt-launcher
If you have created the script files, made them executable and configured your launcher.conf file, you are able to publish the correct payload (on) to the correct topic and your casting of the web page will start. Stop the casting by publishing the correct payload (off) to the topic.
In a next post I will explain the Node Red flow to control the Google Nest Hub.