Sunday, January 8, 2017

Google Home - Intercom - using HASS (Home Assistant)

Here's an intercom i put together using the following:
Once you have HASS working and can cast to Google Home or any Google cast device you simply need to create an IFTTT applet using maker


Now create an IFTTT applet at https://ifttt.com/


create a New Applet




Choose + this




Choose the Google Assistant service




Choose the phrase with a text ingredient





Enter the desired phrase to kick off the request
and use $ where you want your input.
You may also choose a custom response -- including
the $ if you want the phrase repeated in the response





Now choose + that



Choose the Maker action service 



web request




URL:  This is an externally accessible URL to your HASS instance
Method: POST
Content Type: application/json
Body:  add your device name.. as shown at /dev-state







Click Finish to save you new applet 



If everything went well it should look like the following



Create a additional applets to call other rooms

Saturday, January 7, 2017

Google Home - Intercom - using google-home-notifier

Here's an intercom i put together using the following:

First install and run google-home-notifier as instructed on his page (linked above)
I installed this on my Pi

When you start up the example.js as mentioned, it will give the following when it is ready to receive requests:
POST "text=Hello Google Home" to:
        http://localhost:8080/google-home-notifier
        https://*******.ngrok.io/google-home-notifier
    example:
    curl -X POST -d "text=Hello Google Home" https://*******.ngrok.io/google-home-notifier

For my application, I use the line referencing localhost info but changed localhost to the server it was running on since my php code is on a different box.

http://localhost:8080/google-home-notifier
to
http://ip_of_pi:8080/google-home-notifier

Next, create a php script similar to mine below:

change ip_of_pi in the code to the ip of where you installed google-home-notifier


The $url in the code was just for this write up but your should use an https connection and credentials since this is externally accessible

announce.php

    $url = 'http://ip_of_pi:8080/google-home-notifier';
    $post_data = "text={$_GET['sayWhat']}";
    $ch = curl_init();
    curl_setopt($ch,CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
    $return = curl_exec($ch);
    curl_close($ch);




Now create an IFTTT applet at https://ifttt.com/


create a New Applet




Choose + this




Choose the Google Assistant service




Choose the phrase with a text ingredient





Enter the desired phrase to kick off the request
and use $ where you want your input.
You may also choose a custom response -- including
the $ if you want the phrase repeated in the response





Now choose + that



Choose the Maker action service 



web request




Enter the url where your php code can be reached (needs to be externally accessible)
{{TextField}} is the $ item received as part of the + this from above
Method: GET
Content Type: text/plain




Click Finish to save you new applet 



If everything went well it should look like the following



Create a second js file and a second IFTTT applet for calling the 2nd (or more) room(s)