Android Plugin

Discussion and support for individual OSA plugins
Post Reply
Message
Author
fiveHellions
Posts: 86
Joined: Wed Feb 06, 2013 12:12 pm

Android Plugin

#1 Post by fiveHellions » Fri Apr 26, 2013 11:41 am

I'm thinking of building an Android plugin. I know there is an Android app and you can use the mobile website or something like open remote to control OSA. But I was thinking more of an extension of OSA than a remote control. Write a plugin for the communication and create objects for each android device you want to interact with in OSA.

There are a few areas I'd like to start off building:

Notifications.

It would be nice to use an android device for notifications. And to be able to define how you are notified for different messages. Some you could put a message in your notification drawer, others play a sound or even have it speak the message on your phone just like the speech plugin does. I think it could have different message types and levels and then you define how each type is presented. Maybe have profiles too so depending on when you’re at home or away or at work it could deliver messages differently.


Actions on your phone trigger events in OSA.

It would be cool to integrate with tasker or similar apps. And have them be able to call methods in OSA as part of the task. For example you set up a tasker task when you get within a certain distance from home it calls a method to open your garage. Or the opposite you leave your neighborhood and it tells OSA to run a method and make sure you turned certain appliances off or turns down your AC or notifies you that you forgot to set the alarm. Or when you set your phone on the charging dock at night it automatically turns off all the lights. Or when you get an incoming text it sends to OSA to read it aloud to you or show a message in your media center. Turns the volume down or pauses when you get a phone call.

I figured it would be easier to leverage apps like tasker to define events on your phone then write that piece again. Just simply make it where tasker can call an intent in an OSA android app that could then trigger a method on your server.


Events in OSA trigger events on your phone.

The opposite of the above. Be able to have OSA perform actions like set phone to vibrate when you play a movie. Or when you’re playing media stops it turns your phone screen on and opens your remote app so you can start your next show or movie. Again it would be easiest to leverage apps like tasker. Just be able to call tasker tasks from OSA.

Those are my thoughts but before I got started building it I wanted to get ideas from everybody else on what sort of integration you would like to see with your phone or tablet. And also any suggestions on how it should work.
Last edited by fiveHellions on Wed May 15, 2013 10:46 am, edited 1 time in total.

User avatar
bwoodworth
Site Admin
Posts: 1563
Joined: Tue May 04, 2010 6:49 am
Location: California

Re: Possible Android Plugin

#2 Post by bwoodworth » Fri Apr 26, 2013 12:08 pm

I love the idea. it would be pretty cool to have a nice integration between OSA and android phones. I beleive some of the itmes you mentioned are already possible with Tasker. I think you can call a url as a task in Tasker and this can be the REST API in OSA to run methods, etc. It would be nicer to have a better integration than that, but it is possible
Brian

fiveHellions
Posts: 86
Joined: Wed Feb 06, 2013 12:12 pm

Re: Possible Android Plugin

#3 Post by fiveHellions » Fri Apr 26, 2013 2:57 pm

Yeah I'm actually experimenting with using tasker to send a rest command and set me as home or away based on GPS location. That's what got me thinking about more android integration. Previously I was using the network monitor to see when my phone and tablet were online and then timing out after 30 min of being offline.

So the only thing better would be letting you select methods from a list instead of having to know the correct url for the rest command.

I also think we could have several standard events like incoming call or text linked to an event on the android OSA object. That way for simple stuff users won't even have to mess with tasker.

And having OSA control your phone is something I'm not aware of a way to accomplish currently.

Datahead
Posts: 711
Joined: Fri Jan 27, 2012 6:50 am
Location: San Marcos, Ca.

Re: Possible Android Plugin

#4 Post by Datahead » Fri Apr 26, 2013 3:27 pm

fiveHellions,
This plugin looks very interesting after looking at tasker and reading your plans for an android app. At present I am using Open Remote and I have to say it work quite well but with that said it was a bear to setup as the WebUI for Open Remote has something to be desired, but once it is set up its done.

It would be nice to actually have an app that is OSA based rather than using a secondary application and from your post it sounds like this app will be able to do things that OR cannot. I look forward to seeing how your project turns out.

Ron

fiveHellions
Posts: 86
Joined: Wed Feb 06, 2013 12:12 pm

Re: Possible Android Plugin

#5 Post by fiveHellions » Wed May 15, 2013 10:28 am

I'm ready to release the first go at phase 1 (notifications) of my android plugin.

It's only functionality now is to be able to send notifications to your android device. You can customize it to play sounds, vibrate and speak the text for different categories and levels.


How to Start Using:

1. download and install the plugin from here. http://www.opensourceautomation.com/plu ... 08f522c03c

2. verify that the plugin starts correctly and has created the correct object types.

3. download and install the android apk from here. https://dl.dropboxusercontent.com/u/433 ... ension.apk

4. open the app and it will guide you through a wizard to set up your device to receive notifications. (you will need to be on local network or have port 8732 open for REST communication with OSA during the setup process, after setup you do not need to be on local network or have access to REST port to receive notifications)

5. if you want to send a notification to all devices simply add the line below in a powershell script (parameter2 is a two part parameter combining the category and level separated by a comma)
invoke-osa -name "Android" -Method "Notify All" -parameter1 "This is my message" -parameter2 "mycategory,5"

6. if you want to send a notification to just one device
invoke-osa -name "AndroidDeviceName" -Method "Notify" -parameter1 "This is my message" -parameter2 "mycategory,5"

7. in Android go customize each category to notify you how you want


Notes:

This uses Google Cloud Messaging to send notifications. These notifications are push notifications so there is no constant polling to get messages. This should help with battery life. But currently all notifications will wake the device, so alot of messages could affect battery life. As part of GCM you can specify if the message should be delivered immediately and wake the device or be received the next time the device is awake. So in a future update I will either add another part to parameter2 to specify if the message should be delivered immediately or base it on the level (ie level 1-5 will wait and level 6-10 will wake the device)

The alert sounds and speech in the android app are streamed on the notification stream so they will use notification volume. If there is any interest I could add and option to change the stream type (media, phone, alarm, ect) to have these play on another stream. This could be a global option or by category.

This apk works for 2.2 froyo and above. If anybody has an older device they want to run this on (cheap tablet as a remote) let me know and I can see what changes I need to make to have it work on older devices.

fiveHellions
Posts: 86
Joined: Wed Feb 06, 2013 12:12 pm

Re: Android Plugin

#6 Post by fiveHellions » Wed May 15, 2013 10:47 am

By the way I haven't done much testing on older devices or smaller screen devices.

So if you notice any bugs or any screens that don't fit or look right let me know.

User avatar
Mat
Posts: 501
Joined: Thu Aug 09, 2012 2:35 pm
Location: UK

Re: Possible Android Plugin

#7 Post by Mat » Wed May 15, 2013 10:49 am

Hey fiveHellions,

I'm intrigued I will have to give it a go when I get home. When it comes to checking in your Android code, there is a separate project for Android: https://github.com/opensourceautomation/Android your plugin will still go under the normal project.

I like your Android/OSA icon combo :D

fiveHellions
Posts: 86
Joined: Wed Feb 06, 2013 12:12 pm

Re: Android Plugin

#8 Post by fiveHellions » Wed May 15, 2013 11:01 am

Thanks. I will upload the plugin code and the android code later today or tomorow.

Eventually we can merge the two android apps into one. I started a new one because I'm lazy and thought it would be easier for me to start fresh instead of fit it into an existing app. But there is no reason they can't be combined down the road.

The icon needs to be cleaned up. I started with an OSA logo that wasn't that big and therefore the quality sucks (plus I'm definately not a graphic artist). But its good enough for now. I like how the two merge together too.

User avatar
bwoodworth
Site Admin
Posts: 1563
Joined: Tue May 04, 2010 6:49 am
Location: California

Re: Android Plugin

#9 Post by bwoodworth » Wed May 15, 2013 11:06 am

This looks very exciting. Would it be possible in the future to combine Mat's app and your into one app? If so, I think we will have pretty nice OSA app we could release on the Play store.
Brian

User avatar
Mat
Posts: 501
Joined: Thu Aug 09, 2012 2:35 pm
Location: UK

Re: Android Plugin

#10 Post by Mat » Wed May 15, 2013 11:30 am

I did a bit of playing with the Icon for my Android app, but like your self im not an artist the transparency made it difficult to see the icon a bit on mine I found. It looks like your app supports older versions of Android than mine did, but it would be nice to merge the functionality. Im not sure how much Android experience you have but it was my first go at Android Apps so u may look at the code and Cry lol but it works and seems to be robust from the testing that I did. A bit more fine tuning and... I just haven't had time as I have been helping a lot with other bits.

I remember you saying you Phone auto registered in OSA with the App which was a nice touch. Sending an image in a notification would be a nice feature (not sure how I would achieve it without a bit of pondering). That way if a camera motion triggered or such you could send an image of what it saw as a notification.

Post Reply