With a bit of spare time over the Christmas break, I have been working around with my google home and PiHome. I was ready to buy a boost console from PiHome but decided to try my own attempts first. Rather than using a physical button, I decided to try voice commands instead. Below is the description of how I got there – I’m sure you can think of a number of improvements/ a much simply way of coding this, but you might find it useful.

The Goal

  • Link Google assistant to PiHome in order to:
  • Issue voice command to activate each boost zone
  • Issue voice command to stop all current boost/schedules

The Method

Rather than risk over loading my PiHome Raspberry pi 3B – I decided to run all voice related tasks via a separate Raspberry Pi. After much research into MQTT, I decided I was way outside my knowledge base and decided to use a much simpler interface – `node-red` – to handle all coding. I’m sure it is possible to do this via MQTT which would easily run via a Broker on the PiHome Raspberry pi for someone with more knowledgeable in these subjects.

This is the information route I will be using to accomplish the goal.

PiHome IFTTT Google Assistance and Node-RED

PiHome IFTTT Google Assistance and Node-RED

In Essence

Talk to google assistant
The trigger phrase is picked up by IFTTT
IFTTT then issues a `webhook` (with a comfortable amount of security)
Node-Red then picks up this `webhook` and converts the response into a string
Dependant on the phrase – `node-red` sorts the command into a update statement for SQL for the `Boost` database

Steps to Accomplish The Task

  1. Set up Raspberry pi with Buster (I choose to run with Raspbian Buster Lite)
  2. Set up Node-Red
  3. Setup Apache, MySQL Server and PhpMyadmin (LAMP), I followed these instructions to the letter –
  4. Assuming you already have a google home device and an IFTTT account…then you simply follow these steps 
  5. To set up my Google Assistant trigger phrases I decided to run with the following: Trigger Phrase = `Boost Downstairs` – this sends the following message body via webhooks as a JSON post `{ “action”: “boost_downstairs_on” }` (all set out in the link in step 4)
  6. This is my node red setup.

Note. I have ‘node-red-contrib-webhookrelay’ & ‘node-red-node-mysql’ installed as extra node inputs/outputs.

Node-RED Contrib Webhook Relay

Node-RED Contrib Webhook Relay

As you can see once the phrase triggers a webhookrelay. I then extract the body, convert to JSON and then determine which boost zone to activate via an SQL update to the database.

Note. If you’re wondering why I have multiple update statements, I have 2 zones per floor, so I have to trigger 2 boosts before the boiler and zone value kick-in.

The ifttt trigger allows you to set an automated response. In my case, when I say “hey google, boost downstairs heating” – google responses “okay, heating turned on downstairs for 1 hour”.

Note. This is a dumb statement. For now google cannot determine the status of the boost (acknowledge/confirmation), it can only blindly issue a command and hope the SQL table gets updated.

This has worked flawlessly for the last few days. It’s complicated only because of my lack of Php/Python coding. Also as I have decided to run this on a separate raspberry pi (for now). I have created an additional user within MariaDB and granted privileges for this user to query/update via a set IP address.

But I am working in the next phase, where I can query zone temperatures and schedules/boost/boiler status and have google speak them back to me. A number of people have accomplished this via the google-notify (TTS) node.

I will forward details as soon as I have it working.

This is an export of my node-red palette, you can import this node directly as a template, but it will need to be populated with your own webhookrelay security info and database login details.

[{"id":"e7245338.cd562","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"9e93e70e.3439f8","type":"webhookrelay","z":"e7245338.cd562","buckets":"","x":130,"y":80,"wires":[["a19248ed.204f4"]]},{"id":"a19248ed.204f4","type":"function","z":"e7245338.cd562","name":"extract body","func":"\nreturn {\n payload: msg.payload.body\n};","outputs":1,"noerr":0,"x":330,"y":80,"wires":[["2735c71.92a00b8"]]},{"id":"2735c71.92a00b8","type":"json","z":"e7245338.cd562","name":"","property":"payload","action":"","pretty":false,"x":510,"y":80,"wires":[["4f4a5f8e.05b208"]]},{"id":"4f4a5f8e.05b208","type":"switch","z":"e7245338.cd562","name":"","property":"payload.action","propertyType":"msg","rules":[{"t":"eq","v":"boost_downstairs_on","vt":"str"},{"t":"eq","v":"boost_upstairs_on","vt":"str"},{"t":"eq","v":"boost_hot_water_on","vt":"str"},{"t":"eq","v":"heating_off","vt":"str"}],"checkall":"true","repair":false,"outputs":4,"x":250,"y":220,"wires":[["5498818.f0c96","591a0a2.2da97f4"],["963312b2.c4e34","febec1f9.096768"],["33455dd4.2ccd92"],["96cb2d05.607c8"]]},{"id":"5adc541c.460714","type":"debug","z":"e7245338.cd562","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":1030,"y":340,"wires":[]},{"id":"5498818.f0c96","type":"function","z":"e7245338.cd562","name":"SQL Update downstairs on","func":"msg.topic = \"UPDATE `boost` SET `status`=1 WHERE `zone_id`=39\"\nreturn msg;","outputs":1,"noerr":0,"x":580,"y":200,"wires":[["415f60d1.70b4e8"]]},{"id":"96cb2d05.607c8","type":"function","z":"e7245338.cd562","name":"SQL update all heating off","func":"msg.topic = \"UPDATE `boost` SET `status`=0\"\nreturn msg;","outputs":1,"noerr":0,"x":570,"y":400,"wires":[["415f60d1.70b4e8"]]},{"id":"963312b2.c4e34","type":"function","z":"e7245338.cd562","name":"SQL Update upstairs on","func":"msg.topic = \"UPDATE `boost` SET `status`=1 WHERE `zone_id`=41\"\nreturn msg;","outputs":1,"noerr":0,"x":570,"y":280,"wires":[["415f60d1.70b4e8"]]},{"id":"33455dd4.2ccd92","type":"function","z":"e7245338.cd562","name":"SQL Update hot-water on","func":"msg.topic = \"UPDATE `boost` SET `status`=1 WHERE `zone_id`=35 AND `duration`=30\"\nreturn msg;","outputs":1,"noerr":0,"x":570,"y":360,"wires":[["415f60d1.70b4e8"]]},{"id":"415f60d1.70b4e8","type":"mysql","z":"e7245338.cd562","mydb":"","name":"SQL","x":850,"y":340,"wires":[["5adc541c.460714"]]},{"id":"591a0a2.2da97f4","type":"function","z":"e7245338.cd562","name":"SQL Update downstairs on","func":"msg.topic = \"UPDATE `boost` SET `status`=1 WHERE `zone_id`=40\"\nreturn msg;","outputs":1,"noerr":0,"x":580,"y":240,"wires":[["415f60d1.70b4e8"]]},{"id":"febec1f9.096768","type":"function","z":"e7245338.cd562","name":"SQL Update upstairs on","func":"msg.topic = \"UPDATE `boost` SET `status`=1 WHERE `zone_id`=42\"\nreturn msg;","outputs":1,"noerr":0,"x":570,"y":320,"wires":[["415f60d1.70b4e8"]]}]

Thank you Paul Geoghegan the author of this post sharing this with me and with PiHome community.