I started using Home Assistant a while ago and I find that it integrates well with my existing Node-RED / MQTT setup. It’s possible to control Home Assistant with Google Assistant if you use Home Assistant Cloud, but I’d prefer to control it locally so I used the Home Assistant Python API to add basic commands to my AIY Project setup.
The mods can be found here: https://github.com/ktinkerer/aiyprojects-raspbian/blob/voicekit/src/home_assistant_commands.py
You will also need the my_config.py file: https://github.com/ktinkerer/aiyprojects-raspbian/blob/voicekit/src/my_config.py filled in with the IP address of your Home Assistant setup, your Home Assistant password and if you want to use a notify platform on Home Assistant the name of that service. Place this in the ‘src’ folder alongside the home_assistant_commands.py file.
The Home Assistant API comes bundled with the Home Assistant package so if you are running Home Assistant on a different pi to the one you are running the AIY Project on you will need to install Home Assistant on the AIY Project pi (pip3 install homeassistant), but you don’t need it to be running. I couldn’t find a way to install just the API. If you are running both on the same pi it should just work.
Currently this supports:
get_state Report the state of a Home Assistant entity. I’ve used the outside temperature as an example.
set_state Set the state of a Home Assistant entity, could be used for switches, lights or as in my example automations.
notify Uses the Home Assistant notify platform to send a message. In my example if you said “Notify remember to buy milk” you would receive the notification “remember to buy milk”.
To test these mods place both files in your ‘src’ folder, modify my_config.py and home_assistant_commands.py to suit your Home Assistant setup. Stop the the voice-recognizer service if it is currently running and from your aiyprojects folder run the mods using the command
env/bin/python3 -u src/home_assistant_commands.py
To copy the mods into an existing AIY Projects file don’t forget the imports:
import homeassistant.remote as remote
then copy the home_assistant function, add your own functions that call the home_assistant function and add your custom voice commands to the process_event function.