Software apps and online services
“Why use 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.
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
- IFTTT Applet take action of making HTTP request to PHPoC
- PHPoC performs a work according to that phrase (e.g. turn on/off the light)
- 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
Refer to this link.
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.
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.
In search box, type “Google Assistant” and then click the 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 the $ symbol represents an ingredient. An 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.
In search box, type “maker”, click “Maker Webhooks”.
Choose make a web request:
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.
Review and finish. Click “Finish” button.
Click “check now” button.
Now upload source code to PHPoC and test it with Google Home.
See index.php in code section.