Here's how to control an Android device with Vera

I have an old phone hooked into a whole house speaker system that I used for sending audio text-to-speech alerts with Vera Alerts. Since the phone can do other things, my goal was to get Scanner Radio working on a Virtual Switch so I could turn on/off my local police scanner.

On your Android Device:

  • Install FTPServer
    • Create a directory using File Manager or Root Explorer, I created /sdcard/vera
    • Launch FTPServer and create a user that is chrooted to that directory
    • Set the port to 2121 (default port of 21 not allowed since the server doesn’t run as root)
    • Click the Save and Restart Server button
  • Install Tasker and Scanner Radio Locale plugin
    • Create a task that starts FTPServer on boot so you don’t have to manually start it on reboot
    • On your local machine, create two files (ScannerOn.tmp and ScannerOff.tmp). They can be empty, or have a single letter or number of your choosing in them.
    • FTP these to your android device
    • Create a Profile based on Event->File Modified and select ScannerOn.tmp
    • Create a new task for it that uses Plugin->Scanner Radio (you’ll have to have configured your favorites in scanner radio first) and starts playing on the selected favorite
    • Create a new Profile that monitors ScannerOff.tmp and associated task that stops Scanner Radio

On Vera:

  • Install the Virtual Switch app
  • Rename the Virtual Switch device to “Police Scanner”
  • Create a new scene called “Police Scanner Control”
  • Click the triggers tab and create a trigger for when your Police Scanner virtual switch is turned on. Once it’s created, click the LUUP code button next to it and insert this code changing the values for your android device/ftp server appropriately:

[code]local ftp = require(“socket.ftp”)
local ltn12 = require(“ltn12”)
– change host, user, and password
f, e = ftp.put{
host = “10.32.32.50”,
port = “2121”,
user = “vera”,
password = “password”,
command = “appe”,
argument = “ScannerOn.tmp”,
source = ltn12.source.string(“z”)
}

return f[/code]

  • Create another trigger for turning it off and insert the following LUUP code on the trigger:

[code]local ftp = require(“socket.ftp”)
local ltn12 = require(“ltn12”)
– change host, user, and password
f, e = ftp.put{
host = “10.32.32.50”,
port = “2121”,
user = “vera”,
password = “password”,
command = “appe”,
argument = “ScannerOff.tmp”,
source = ltn12.source.string(“z”)
}

return f[/code]

  • Save it, Confirm Changes, and click the red save button in the top right to restart LUA engine

Basically, what this is doing is when you change the virtual swtich status, a single letter “z” is appended to the file on the android device over FTP. You need to use the “appe” option in the code above, because when you overwrite a file with the put command in FTP, Tasker is not able to tell that it’s been modified. Once the file is appended, Tasker sees the change and executes the profile which starts or stops Scanner Radio. Yes, the file keeps growing be 1 character every time you turn the virtual switch on or off. It’s gonna take a long long time to ever get to a size that causes issues. You can always re-upload an empty file.

I know that there are Android push services that can be used for triggers in Tasker. The reason I did it this way is that I do not want to have to rely upon an internet connection for controlling the android device. I know Scanner Radio needs an internet connection, but I may automate other things that do not. I just don’t feel like relying on an internet connection and 3rd party services for home automation is a good idea. If I could figure out how to make tasker just listen on a TCP socket, this would have been easier. But for now, this works very well.

In theory, you could use it to control music players, there’s a weather announcement plugin for Tasker that uses the built in TTS engine, you can make it send IM’s via different IM services, SMS’s or phone calls if you have a SIM in the phone, etc.

If you use Tasker, you should take a look at AutoRemote. It’s a plugin to control Tasker from an htp request sent to the C2DM cloud


via Samsung Galaxy S avec Tapatalk

Will this work with any version of Android ?

(I’m an iOS user, but tempted by an Android due to some of the thing it can do, unless there is a way to do all this on a iOS device too?)

@signal15 - I have also asked you a specific FTP question in your other/related post

[quote=“Shaigan, post:2, topic:173613”]If you use Tasker, you should take a look at AutoRemote. It’s a plugin to control Tasker from an htp request sent to the C2DM cloud


via Samsung Galaxy S[/quote]

Good idea, however I’m assuming this is better than waiting for the c2dm until RTS allows for local control of vera alerts. Only because of the delay…

Sent from my SPH-D710 using Tapatalk 2

In my case, it’s nearly instant :wink:

My delay is roughly 2 seconds on avg

Sent from my SPH-D710 using Tapatalk 2

[quote=“Shaigan, post:2, topic:173613”]If you use Tasker, you should take a look at AutoRemote. It’s a plugin to control Tasker from an htp request sent to the C2DM cloud


via Samsung Galaxy S[/quote]

Again, I don’t want to rely on a 3rd party service or an internet connection for any of my automation.

Sent from my Galaxy Nexus using Tapatalk 2