What: If you ever wanted a cheap, portable, dedicated “box” which would announce by voice certain status changes from Felix’s excellent moteino/raspberry pi gateway, then the approach below might be of interest. For example, if the garage door is opening, this device could say something cleaver like “The garage door is opening”.
Why: I have my primary cell phone set up to receive a SMS text message from the Gateway for certain critical conditions from the Gateway (like my water leak detector). These messages need to get to me even if I am away from my house (as long as I have cell service). Verizon claims they have me covered
However, for less critical announcements, what I wanted was a small device which I could stick in the corner of a room which could speak.
How: The approach I got working simply uses an a old cell phone without cell service to speak a phrase based on receiving a HTTP Post Request with a single trigger word. No other hardware is required. The software is very simple. The Gateway to phone communication remains on your local wifi network and the messages never depend on external SMS or email servers. For me, the phone is a dedicated box for this task. By the way, cell phones are amazing devices for repurposing. There is no way for a do-it-yourselfer to build something with as many technical features for such a low price. If you do not have an old unused phone, a new pre-paid phone can be found at local Walmart or grocery stores for under $20, or sometimes under $10 on a sale. Unlocking or rooting the phone is NOT required for this project to work. Installing two Google Play Store apps alleviates the need to write any software for the phone.
I tried to provide enough steps below to make duplicating this an easy project.
BEGIN CELL PHONE SETUP
1. Reset old phone to factory and set up WiFi to your network then set up Gmail to your account. Don’t use a primary Gmail account; make one specifically for these kinds of electronics activities. If you don’t have an old unused phone I would recommend buying a new GSM based prepaid phone with android 4.4.2 or higher. Remove the SIM card before turning it on since the phone does not need to be activated.
2. Settings > Sound > notifications max , all others low as possible
3. Settings > Language and Input > Text-to-speech options pick one for your phone
4. Install Tasker by Crafty Apps EU, $3 to buy (from the google play store)
https://play.google.com/store/apps/details?id=net.dinglisch.android.taskerm This app allows you to set up multiple profiles, each to do certain tasks (say something) based on contexts being met (receiving a trigger word from the Gateway). Tasker is very powerful, but I stayed in beginner mode (so far).
5. Install Tasker Network Event Server (TNES) by TActHab (from the google play store),
https://play.google.com/store/apps/details?id=bidoismorgan.httpevent This free app has a HTTP server that can handle GET and POST requests on port 8765. This is a Tasker plug-in which allows Tasker to trigger events when receiving messages over the local network from the Gateway.
6. Here is an example of how I set up a Tasker profile to say “You got mail” when TNES receives a new a post request message with the single word “mail”. I set up a few different Profiles, one for each task, such as “open” to announce the garage door was opening. I installed this on two phones: an old Verizon Samsung Galaxy S3 running Android 4.4.2 (Kit-Kat) and a new ATT Go Phone, ZTE Maven Z812, running android 5.1 (Lollipop).
Tasker > Profiles > SetSort > User > + > Event > Plugin > TNES > Configuration edit > delete the Remote broker address (leave blank) > Event name: sayMail > Filters: mail > [press top left < button TWICE to get back to Enter Task > newTask + > SayMail > + > Alert > Say > text You got mail. > engine: voice search Samsung-text-to-speech-engine-engUSA > stream notification > Respect Audio Focus and Network [check both to enable]
END CELL PHONE SETUP BEGIN MODIFICATIONS TO GATEWAY
Add the following to metrics.js Events of the raspberry Pi Gateway software by Felix. I am still using version 6.
mailboxTasker : { label:'Got Mail-> Cell phone speak ', icon:'info', descr: Send http post so old cell phone can announce event', serverExecute:function(node) { if (node.metrics['M'] && node.metrics['M'].value == 'MAIL' && (Date.now() - new Date(node.metrics['M'].updated).getTime() < 2000)) exports.taskerRequest('mail'); } },
Add the following to metrics.js after the end of the helper functions
// this function sends an HTTP POST request to the Tasker and TNES app web server
// running on the two android cell phones
exports.taskerRequest = function(triggerWord) {
request.post({
headers: {'content-type' : 'application/x-www-form-urlencoded'},
url:'http://192.168.1.60:8765', // Galaxy S3
body: triggerWord },
function(error,response,body){ }
);
request.post({
headers: {'content-type' : 'application/x-www-form-urlencoded'},
url:'http://192.168.1.62:8765', // ZTE Maven
body: triggerWord },
function(error,response,body){ }
);
}
END MODIFICATIONS TO GATEWAY
Don’t forget to add the EVENT to your Gateway web page.
**********
Some Notes:
**********
I used the term cell phone in the above write-up, but I’m sure you recognize this should work for many other android devices such as tablets, providing they have wifi, a speaker, and Android current enough to run the apps. What about Apple Fanboys? The short answer is I have no clue if there are similar apps for IOS and what their configurations might be.
When you are on the TNES configuration page, notice the HTTP server address at the top of the page. This is the cell phone local URL (actually of the TNES server). It is a good idea to assign your cell phone with a static IP address in your WiFi router so it doesn’t change over time. Also the TNES configuration filters work better in all lower case letters.
My old Samsung Galaxy S3 phone was picky on the text to speech engine selected in the TNES tasks. If I chose the Google engine, there was a larger delay before the speech started (compared to the ZTE Maven) and about 10% of the time the S3 wouldn’t speak. I guess a Samsung phone just likes a Samsung engine.
There are alternatives to TNES which are more popular, like AutoRemote, but I found TNES easy to use and free.
https://play.google.com/store/apps/details?id=bidoismorgan.httpevent&hl=en How to use network events for Tasker with TNES plugin
http://thacthab.herokuapp.com/TNES.htmlAs an option, the Tasker app has a7 day trial version (direct download
http://tasker.dinglisch.net/index.html However, to use the direct download, you have to enable Unknown Sources under you phones Security setting. Also, you cannot pay the $3 from inside the app. You have to uninstall the direct download and then install the $3 play store app.
Tasker is very powerful, but I did not use any advanced features. If you want to do more with Tasker here may be a useful guide as well as a link to the reddit tasker forum:
http://www.pocketables.com/2013/05/beginners-guide-to-tasker-part-1-5-tasker-basics-new-ui.html https://www.reddit.com/r/tasker/When in Tasker, the phone menu button brings up a dialog box for preferences, backup, etc.
One tool I used to debug this project was the Advanced RestClient extension to the Chrome browser on my PC. The settings below allowed me to send a message to my cell phone. So, when that part worked, then I could concentrate on getting the Gateway metrics.js syntax correct.
http://192.168.1.60:8765 > POST > Headers: Content-Type: application/x-www-form-urlencodedOne > Payload: mail [then press the Send button and your phone should trigger]
Actually, as a first step to make sure the android (TNES) is running, just paste the phone url, in my example that would be
http://192.168.1.60:8765 , into any browser and press return. This will display a very small Hello World web page served by TNES.
I have no risk in providing my actual IP address for my phone in this forum since it is local to my LAN only. That address is not available from the WAN. For these HTTP posts, what goes on in my LAN stays in my LAN.
I tried a couple simple tests. I streamed a Netflix movie and monitored the Gateway Dashboard web page while sending multiple “mail” messages through the Gateway to the two phones. No issues. I powered off one phone and repeated. Only one phone spoke, but no unexpected issues. Powered off both phones, no unexpected issues. Powered back on both phones and [after a couple minutes] they automatically ran Tasker and spoke as intended without any other button pushes. Great.
Please post here if you find any major issues with my steps. I would also be interested if you expand the capabilities.
*************
End of my post.
-- - Duane
*************