Back to home
Google home automation Simple project, i just wanted to attach my home remote light switches to my google home.
For this you will need:
In my case, i do have a nice rfxcom trx433E, but there's other methods, including using an arduino with some transeiver module

Setting up the raspberry pi The raspberry couldn't be simpler: Once done, eject the sdcard and insert it in the raspberry pi.
Now boot up the pi. It will reboot once or twice, but eventually it will show up with a login prompt.

login using the default username/password: pi/raspberry
Make sure to change that default password by using the command: passwd

next, check your ip address
ip addr show

If SSH seems to have a problem:
reset ssh certificates
sudo rm /etc/ssh/ssh_host*
sudo dpkg-reconfigure openssh-server
Now activate ssh and set the correct timezone:
sudo raspi-config
SSH can be activated under the menu 5, interfacing options. The timezone is under 4, localisation options

While logged in, might aswel update the os:
sudo apt-get update
sudo apt-get upgrade -y

#(once it finished everything)
sudo reboot
Last, set a static ip for the system:
static ip
sudo nano /etc/dhcpcd.conf

# now add the following in that file
interface eth0
static ip_address=
static routers=
static domain_name_servers=

# hit ctrl-x and save the file to exit.
With that, the basic system is finished!
Setting up domoticz Domoticz is a free opensource software that we can use to first get things working using our RF hardware.
Installation is pretty simple again:
Domoticz install the easy way
curl -L https://install.domoticz.com | bash
Just let it run and do it's thing.
set up monitoring:
MONIT monitoring install
sudo apt-get install monit
sudo nano /etc/monit/monitrc

# add:
set httpd port 2812
 use address 0.0.0.0  							# only accept connection from localhost (comment to connect from other hosts)
 allow 0.0.0.0/0.0.0.0     				# allow anybody to connect to the server and
 allow admin:monit         				# require user 'admin' with password 'monit', change if your system is accessible from internet

#if you like monit to email you:
set mailserver  port 587 
username "yourmailaddress@gmail.com" password "MYPASSWORD"
using tlsv1
with timeout 30 seconds
set alert email@yourdomain.com

# store it
sudo nano /etc/monit/conf-enabled/domoticz

# enter the text
check process domoticz with pidfile /var/run/domoticz.pid
start program = "/usr/bin/sudo /bin/systemctl start domoticz.service"
stop  program = "/usr/bin/sudo /bin/systemctl stop domoticz.service"
# use below start/stop command for older systems not using systemctl
# start program = "/etc/init.d/domoticz.sh start"
# stop  program = "/etc/init.d/domoticz.sh stop"
if failed
   url http://127.0.0.1:8080/json.htm?type=command¶m=getversion
       and content = '"status" : "OK"'
   for 2 cycles
   then restart
if 5 restarts within 5 cycles then exec "/sbin/reboot"

#and again, store and save it

#check validity of the config:
sudo monit -t

#if it all checks out:
sudo service monit start
sudo monit status

Now, configure domoticz itself by starting up a browser on a computer and go to the url: http://<YOUR IP>:8080 and you should see the domoticz page.
First, go to 'setup' and select 'hardware'. Now set up the tranceiver(s) that will be used.
Now, set up the lights/devices/anything you have by teaching it to domoticz
Next, add a room. Under settings go to 'more options', then select 'plans' and last 'roomplans'
Add your room (or multiple) and add the devices you have to the correct room. If there's just one, add it all to that one.
In the 'switches' screen you can click on the star icons to make them show up on the dashboard.

You should now be able to control all the devices using the mouse and clicking on the devices.

Last thing to do is adding a user to use later on. Do this by going to settings again, select 'more options' and then 'edit users'.
Add at least one user, and assign it whatever lights/devices you want google home to be able to control.
Setting up homebridge By far the easiest approach to get things to work is homebride.
It is intended for IOS devices, but with a plugin it is possible to connect it all to google home!
homebridge install commands
curl -sL https://deb.nodesource.com/setup_12.x | sudo bash -
sudo apt install -y node.js gcc g++ make python

#verify node is installed
node -v

sudo npm install -g npm
sudo npm install -g --unsafe-perm homebridge homebridge-config-ui-x
sudo hb-service install --user homebridge
Now, homebridge should be up and running at http://<YOUR IP>:8581
Login using the default username/password: admin/admin


Homebridge domoticz plugin
To have homebridge communicating with domotics, add the plugin for it:
sudo npm install -g homebridge-edomoticz
Now, return to the webbrowser and go to 'plugins'. You will see the homebridge edomoticz plugin. Select settings and enter the information needed there.
The host should be entered as <username>:<password>@<your ip address>
The port number usually is 8080 and just leave the room id to 0, to load all devices.

last, click 'advanced settings' and deselect 'enable mqtt'.



install homebridge google smart home plugin
install commands
sudo npm install -g homebridge-gsh
After that runs, just go to the homebridge page again, go to the plugins page and there should now be a homebridge google smart home plugin.
click on 'settings' and clikc on 'link account'.
Now enter the google account you used in the google home application.
You will get a confirmation on your phone once you do, and allow that access.
Last thing to do: restart homebridge to update everything!
restart commands
sudo systemctl restart homebridge.service
google home setup Setup in google home is pretty straightforward: With that, all configured devices should now be visible in your google home environment.
Choose names As far as domoticz and homebridge are concerned, the names do not really matter. But they do to google! The lights being recognized does depend on wether or not google can make sense of the names of the ligts (or devices)
In the google home app, select the device and give it a name that easy to distinguish and also easy to say, so google can make sense of it.
If you really have to, you can use numbers, but write them out instead of using digits!
It sometimes takes a bit of experimenting, but to test everyting in one go, just yell: hey google, switch all lights on!
Any light that is defined and useable, will then switch on
Otherwise, just name the light and on/off/percentage to set it