Demonstration
“Why uses PHPoC for this project?”. The answer is PHPoC is an IoT hardware platform which has a web server and a variant of PHP interpreter. From PHP script, We can control others device or read value from sensor an send back to client via HTTP response.
How It Works
Google Home -> Google Assistant -> IFTTT Applet->PHPoC
- You say a phrase “turn on/off the light” to Google Home.
- Google Home send it Google Assistant.
- Google Assistant trigger an event to IFTTT Applet
- FTTT Applet take action of making HTTP request to PHPoC
- PHPoC performs a work according to that phrase (e.g. turn on/off the light)
What We Need to Do
- Configure Google Home (e.g. Wi-Fi information, Google Account)
- Create an IFTTT Applet
- Writing source code on PHPoC to handle HTTP request from IFTTT applet
Configure Google Home
Refer to this link https://support.google.com/googlehom...DAndroid&hl=en
Create IFTTT Applet
An IFTTT applet include two components. “trigger and action”. IFTTT stand for “if this then that”, where “this” is trigger, “that” is action.
In this project, trigger is “turn on/off the light” which is created using “Google Assistant” service on IFTTT, and action is “Make a web request” which is created using “Maker Webhooks” service.
So, when the applet is created, “if this then that” becomes “if you say ‘turn on/off the light’ then make a web request”.
Now let’s see how to create it.
1. Create an Applet
Go to https://ifttt.com/ and log in.
Find the button “New Applet” and click
You will see
Click “this” button to create the trigger
2. Create Trigger
In search box, type “Google Assistant” and then click Google Assistant icon
Click “Connect” button.
You will be asked to login into Google account if you did not login. Note that this account must be the same as the account you set on Google Home device. After logging in, you will be back with a screen to choose trigger type. Find and Click “Say a phrase with a text ingredient”.
Fill information as follow:
where $ symbol represent for ingredient. Ingredient is something like argument passed from trigger to action.
For example, if you say “turn on the light”, the text “on” is ingredient and is passed to action.
Click “Create trigger” button. After creating the trigger, the following screen will be shown. Click “that” button to create the action.
3. Create Action
In search box, type “maker”, choose “Maker Webhooks”.
Choose make a web request
Type URL http://domainame_or_ip

http://domainame_or_ip/index.php?state= if the default port (80) is used
In case of you use a private IP, you need to set the port forwarding on your router or access point.
Click “Add ingredient”, select “TextField”
Put other information as shown in below image and click “Create action” button
4. Review and finish
Click “Finish” button
Click “check now” button.
Now upload source code to PHPoC and test it with Google Home
PHPoC Source Code
This code handles HTTP request from IFTTT applet and turns on/off the light
PHP Code:
<?php
include_once "/lib/sd_spc.php";
$text_ingredient = _GET("state");
$is_on = strpos($text_ingredient, "on");
$is_off = strpos($text_ingredient, "off");
if($is_on !== false || $is_off !== false)
{
spc_reset();
spc_sync_baud(115200);
if($is_on !== false)
spc_request(14, 4, "set 0 output high");
else
spc_request(14, 4, "set 0 output low");
}
?>