Monday 11 April 2022

Home Automation : Google Assistant Voice Control

The story so far

We started the Home Automation with a Google Nest Mini and we were able to set it up for voice control of "compatible devices", Sonoff smart power switches and an RGB colour bulb.  I wanted to expand the home automation setup to include other devices.  In particular I wanted voice control of the music system as I dont want to use Spotify/YouTube premium services.

Home Assistant was chosen as a good platform for extra functionality and I have spent some time finding out its capabilities for devices and setting them up.  The most significant device I have added so far is my Linux MPD server, which is my main way of music.  I have also added Pure Jongo devices which are available in various rooms in the house.  

I also have the ability to control these devices, for testing I used webhooks so that I could setup a browser button to trigger actions. I have also the ability to setup the actions in scripts which can be initiated in various ways to make changes.

The last building block is adding voice control to our solution so we have a "modern" home automation setup - I think tablet controls are very much last years thing.

Home Assistant Cloud

We need to integrate Google Assistant (GA) with Home Assistant (HA) if we are to utilise GAs voice control.  This isn't a trivial matter but the excellent HA documentation describes the steps to set it up.  In particular you need to make the HA server available externally on the internet and provide an SSL certificate.  I have done this before for my web-site but adding a second instance makes it more complicated to setup.  As an alternative the guy who set up Home Assistant has an add-on Home Assistant Cloud (HAC) which provides the external functionality between GH and HA for you.  It costs about £4 which I feel is particularly worthwhile as HA is a significant product provided for free and the guy also provides ESPHome which is something I want to use next.

I followed the documentation to setup HAC.  As usual you need to create an account to use the functionality of HAC and signin within HA.  Then you go across to GH on the iPad enable HA integration.  Once this is done I can see the HA devices within GH.

I can also control them, turning lights on and off etc.

In addition to the devices HA has exposed its scripts and scenes to GA.  Thus in GA I can utilise scripts that I have set up in HA to control the devices that GA doesn't know anything about.  This is exactly what we have been aiming for.

The script mpd1 causes MPD to load one of its playlists and start to play it and I now have access to it within GA.









GA Routines

GA automates actions using Routines.  I setup a new Routine in GA which is initiated when I say "start tulip". I can associate actions such as switches and lights with this routine and also Scenes.

I added my mpd1 script/scene as a Tulip action.  Wow, now if I say start Tulip the playlist is loaded and run.

Clearly tulip isn't very mnemonic so I setup playlists in MPD called things like HA-bruce and HA-taylor with suitable track lists.  I then define scripts mpd-bruce and mpd-taylor in HA which load / run the MPD playlists.  I sync these scripts with GA in HA Cloud.  Finally I setup routines "Play Bruce" and "Play Taylor" in Google Home and I can call Bruce (Springsteen) and Taylor (Swift) up whenever I want.

I can use the same technique for any MPD command I want, for example "Play Next" will skip to the next track.


Conclusion

I am very pleased with this result.  I have a flexible generalised solution to my objective.  Within Home Assistant I can define actions on various devices, which aren't available to Google Home. I can then define voice commands in Google Home to carry out these actions.  

This was a proof-of-concept.  I have only scratched the surface of what is possible, but I this has been a very successful experiment.


No comments:

Post a Comment