How To: Tasker Network Event Server - Control your Android device / apps via Vera (TinyCam Pro)

This is an example of controlling from Vera the TinyCam Pro app on an Android device, however this process could be used to control any aspect of your Android device and your Android apps that Tasker and its plugins supports.


I was using Imperihome for viewing my IP cameras however it was janky and never worked great. For one I could not seem to get rtsp streams working in Imperihome so had to add the cameras in to Imperihome as mjpg / Snapshot only.

I was also using the Imperihome web server API to automatically display certain cameras on the Android tablets when something happened in Vera, like the doorbell is pressed or there was motion detected outside on a Z-Wave motion sensor etc. However this also wasn’t great and a lot of times the camera images would not load up and Imperihome would say connection error.

So today I have come up with another solution. I have installed TinyCam Pro on all my Android tablets and added my IP cameras in to TinyCam Pro app using the rtsp stream URLs etc.

I then wanted a way for Vera to be able to launch a particular camera image on the tablet when something happened in Vera as I said, like the doorbell or motion detected on say a Z-Wave motion sensor. Or perhaps when a door / window sensor is opened / closed, you could bring up a camera image automatically on the tablet.

To do this I have used Tasker app and another Tasker plugin app called Tasker Network Event Server (TNES).

I believe you can also use the AutoRemote app with Tasker to do this, but not sure if its WAN only? TNES works locally directly on the LAN no middle man server in the cloud.

Help documentation for TNES here.

So the basic idea is that Vera sends a HTTP command to TNES on the Android device upon the desired event happening in Vera. TNES then fires your linked Tasker action to display the correct camera on the tablet in the TinyCam Pro app.

You can also have a Tasker action to display all your cameras in TinyCam Pro at the same time.

TNES gives you a little HTTP web server in Tasker which is listening for incoming HTTP commands. The port number for TNES is 8765.

After you have installed Tasker and installed TNES you can check that the TNES web server is up and running by entering this in to your web browser on your PC.

http://IP-Android-Device:8765

If its working a Hello World message should be displayed in the browser. Initially whilst testing, this was not working on my Windows 10 laptop as the windows firewall was blocking the outgoing port 8765 so I just added an outbound rule to the windows firewall for that port number.

So how to set this all up in Tasker ?

In Tasker app on your Android device, create a new Profile then select Event from the menu.

Then select Plugin.

Then select Event Plugin - TNES.

Then click the Edit button on Configuration.

image

TNES can be used over the WAN via the Remote broker address http://thacthub.herokuapp.com you can register for an account on there. However as I am doing this only locally over my LAN I had to remove the remote broker address and blank that field.

image

Give your event any name.
Under filters I used the filter: doorbell==show for my doorbell camera.

Next go to Tasks in Tasker and create a new Task, give your new task a name, I called mine “Show Doorbell”.

image

Now add a new Action

and select Plugin

Then select TinyCam Pro

image

Then select the edit button on Configuration.

image

Here you can select “Start app with single camera” or “Start app with multiple cameras” etc. I used single camera.

and selected my Doorbell camera.

image

Select the back arrow on Action Edit.

At this stage on Task Edit, you can press the Play button to check that it launches TinyCam Pro and the correct camera.

Then click the back arrow on Task Edit

Now click the Tick button to save your setup.

image

Ensure the correct profile is linked to the correct task as you can see here.

image

Now to test the HTTP command from your web browser on your PC.

http://IP-Android-Device:8765/?doorbell=show

You should get a response similar to this and the camera should now be showing automatically on the Android device.

image

Obviously you will need to give your Android tablet a static IP address on your LAN.

To send the HTTP command from a Vera scene or PLEG action.

luup.inet.wget("http://IP-Android-Device:8765/?doorbell=show")

Or Curl

os.execute("curl -s -m 15 -X POST 'http://IP-Android-Device:8765/?doorbell=show'")

As I said at the start this could be very powerful for controlling nearly anything on the Android device like turning the screen on or off or launching other apps or basically anything that Tasker can automate on Android you can now send HTTP commands from Vera to run that Tasker action.

4 Likes

After the camera is displayed full screen on the tablet after an event happening in Vera. After 60 seconds I wanted TinyCam Pro to go back to the all cameras view.

So I created a new Profile and Task in Tasker.

image

image

image

I am running my LUA code in some PLEG actions.

I added a 60 second delay and I am calling another Tasker Task for “allcams” to then display the all cameras view in TinyCam Pro.

luup.inet.wget("http://IP-Android-Device:8765/?doorbell=show")
function AllCams()
      luup.inet.wget("http://IP-Android-Device:8765/?allcams=show")
end

luup.call_delay("AllCams", 60)

Here is how I created two HTTP commands to turn off the tablet display and turn back on the tablet display.

I have tried this on a non-rooted tablet and it works also.

New Tasker Profiles

TNES HTTP command for turning off the display

luup.inet.wget("http://IP-Android-Device:8765/?tablet=sleep")

image

For the Task I selected Display and used System Lock

image

TNES HTTP command for turning on the display

luup.inet.wget("http://IP-Android-Device:8765/?tablet=wake")

image

For the Task I selected Display and used Turn On

image

Note: I did try the Turn Off option for Display but it did not work or do anything for me. Which is why I used System Lock instead to turn off the display.

I side loaded TinyCam Pro, Tasker and TNES on to my Amazon FireTV 4k stick.

I used the APK extractor app on my tablet to get the apk files.

And used the Windows adblink application to upload the apk files to the FireTV stick.

And then used the Downloader app on the FireTV stick to install the apk files.

In Tasker I created new profile(s) and task(s) to use the TinyCam Pro plugin for Picture in Picture.

I now have my cameras coming up on the TV screen on the Fire TV stick in PIP upon motion detection events fired via Vera to the Fire TV stick.

Had something similar in Kodi setup on my HTPC using the Cam Overlay plugin for Kodi.

However this is the first time I have had something similar working on a FireTV Stick, so pretty pleased.

1 Like

Just to point out that the network event server Tasker plugin also works in Automate, using the plugin event block.
I have been using it to control my android devices for a while.
I can start apps with predefined actions, open any web page, enable disable immersive mode, change any setting, reboot device, adjust volume, take screenshots, send emails, open file and much more.

1 Like