We have moved at community.getvera.com

Author Topic: Android app building guidance...  (Read 6178 times)

Offline garrettwp

  • Moderator
  • Master Member
  • *****
  • Posts: 6371
  • Karma: +227/-128
  • Vera 3, Lite, ISY994
Android app building guidance...
« on: June 17, 2011, 09:36:24 am »
I am looking at getting into android app development. I do not have much java experience, but have other language experience (html, php, perl, python ...). I am looking at building a vera control app for the honeycomb platform. I just picked up an asus transformer. I have been an ipad 1 user since the initial release. I am probably getting myself into some trouble with starting such a huge project as my first app. But I like challenges and I think it would be a good experience.

I have a few questions for anyone else in the programming field. Especially anyone who knows java. What would be the best way to store the json format once pulled using an async task and httpget? I am stuck on how I would want to store the information. Would it be best to store the least likely changes, e.g. sections, rooms etc and have the devices be stored (cached)? I am trying to find the best way to do this and not hurt on the performance side. I feel that speed is very important. What are the best ways to store the information on the android platform? Should I store them in preferences, database, etc?

I am still looking at how java does things compared to the other languages. Does java have similar things like hash of hashes or multidimensional arrays like in perl? Any guidance would be much appreciated.

Just to let everyone know, this really is just a hobby project and if I can get something working and functional. I will probably release it for free. I really just want to gain more experience in another programming language and build up my skill level.

- Garrett

p.s. one more thing. If anyone would be willing to help out. I am looking for additional user_data2 files to see what everyones configuration is like. This will also help me look at other devices I may not have on my network that others do. So if anyone wants to provide their user_data2 files with me, it would help.

- Garrett
« Last Edit: June 17, 2011, 09:38:52 am by garrettwp »

Offline guessed

  • Community Beta
  • Master Member
  • ******
  • Posts: 5301
  • Karma: +92/-22
  • Release compat is not a bolted-on afterthought
Re: Android app building guidance...
« Reply #1 on: June 18, 2011, 05:02:21 pm »
Garrett,
You may want to start by walking through the JSON parts of a tutorial like this one:
    http://www.ibm.com/developerworks/xml/library/x-andbene1/

There are a zillion of these tut's around the place that'll probably get you started.

For the most part, there are libs that do the work of reading this stuff, and something like the above could be evolved to read (and keep reading) the JSON delivery from Vera.

You might also consider using the sdata instead of the user_data[2], since the latter contains a lot of stuff you really don't need as a Control Point (but do need if you're going to "edit" Vera internals).  It should also cutdown on memory footprint, since the sdata is significantly smaller than the user_data[2], and it has less sensitive data in it (like, no MAC Addresses for each of your UPnP Devices, etc)

For me, I'd leave it in the JSON object, instead of converting it to another datastructure, until I had proof it wasn't suited to the task.  You could spin a lot of wheels "tuning" this before it's time, and early tuning generally doesn't get the results you'd expect.

I suspect you'll want to spend a bunch of time here, just coming to grips with how the HTTP calls to Vera work, both locally, and remotely (and when someone transitions from Local-to-Remote or vice-versa)

Offline automator.app

  • Sr. Member
  • ****
  • Posts: 307
  • Karma: +2/-1
Re: Android app building guidance...
« Reply #2 on: June 21, 2011, 12:17:10 am »
I can say that creating the "network loop" that correctly but minimally retrieves the information from user_data2/status2 while supporting both cp.mios.com and directly connected units is very difficult and time consuming.  I would recommend you start on that part and get the networking/data update portion rock solid before doing the more fun "chrome", especially if you are new to the java language.
Automator.app is dead.

Offline garrettwp

  • Moderator
  • Master Member
  • *****
  • Posts: 6371
  • Karma: +227/-128
  • Vera 3, Lite, ISY994
Re: Android app building guidance...
« Reply #3 on: June 21, 2011, 12:20:14 pm »
Thanks for the advice guys. I am 3/4 of the way done getting the data and storing it. I still have a lot to do on the back end to get it fully functional. Over the course of the year, I have been digging at vera and learning how the api's work. It is a huge learning experience, but hopefully the skills can be carried forward to other things.

I was looking at the sdata route, but in the wiki docs, they say it was best to use the user_data2 for config changes and the lu_status2 for the updates using the dataversion number in the url.

Progress has been slow, but I am getting there. I have been having many issues with my vera unit the last few weeks and I finally came down to do a fresh start with vera and have been trying to get all of my devices and configuration settings back.

- Garrett

p.s. so if the preferred method now using the lu_sdata?
« Last Edit: June 21, 2011, 12:26:18 pm by garrettwp »

Offline guessed

  • Community Beta
  • Master Member
  • ******
  • Posts: 5301
  • Karma: +92/-22
  • Release compat is not a bolted-on afterthought
Re: Android app building guidance...
« Reply #4 on: June 22, 2011, 12:12:09 am »
I'm going by this:

    http://wiki.micasaverde.com/index.php/UI_Simple

and the sample code they wrote:

    http://wiki.micasaverde.com/index.php/UI_Simple_Sample

These were written more recently, and supposedly contain the more modern way to do it.  Obviously, this entry point isn't available in the older releases but it seems to be the way they're going forward.

No idea what version it was introduced since they don't appear to document that.

Offline mramgine

  • Beta Testers
  • Full Member
  • *****
  • Posts: 248
  • Karma: +9/-0
Re: Android app building guidance...
« Reply #5 on: July 24, 2011, 09:14:21 pm »
Make sure you do all the requests in JSON. I would recommend however that you build a class structure that mimics the json format.  Its much easier to work with the data in that format in current object oriented languages like java and C#. I'd focus first on writing a little library that handles downloading the JSON strings and storing them in a friendly object format.  I'd also only focus on UI4.  The vera documentation isn't the best but after numerous emails and trial/error, i was able to write a full featured app for the windows phone platform.  Oh also, you'll want to make sure you build it to be do the web requests asynchronously, otherwise you might get unexpected results with your UI freezing up, etc.  If you got some general questions about the api i should be able to answer them.  Also the Home Buddy dev was really helpful when i was writing my app.
My Z-Wave: 1x Vera (FW 1.0.979, Dongle 2.78), 1x Intermatic HA03C, 1x Intermatic HA05C, 1x Intermatic HA02C, 1x Wayne Dalton WDTC-20

Offline ragmondo

  • Jr. Member
  • **
  • Posts: 51
  • Karma: +0/-0
Re: Android app building guidance...
« Reply #6 on: August 02, 2011, 05:53:39 am »
I've just open-sourced my android app "vera alert" . It doesn't do all the control stuff that you are working on, but it does do immediate alerting which some people have found very useful (myself included). Let me know if you want to work together on this!

Offline garrettwp

  • Moderator
  • Master Member
  • *****
  • Posts: 6371
  • Karma: +227/-128
  • Vera 3, Lite, ISY994
Re: Android app building guidance...
« Reply #7 on: September 18, 2011, 06:47:13 am »
So after spending some time (way too much time!) I have come up with an app for the android honeycomb platform. There is still a lot of things that I need to add and bugs to fix. But so far things are shaping up nicely.

Here is a link to some screen shots of the current state of my application:

https://www.wuala.com/garrettwp/Photos/autHomation/?key=xo0oZz1tDkEJ


I still need to finish adding camera support, tweaking some devices, incorporate scenes to the favorites tab (currently devices only work), add search option, and plenty more on the list. Let me know your thoughts.

- Garrett
« Last Edit: September 22, 2011, 10:10:52 am by garrettwp »

Offline guessed

  • Community Beta
  • Master Member
  • ******
  • Posts: 5301
  • Karma: +92/-22
  • Release compat is not a bolted-on afterthought
Re: Android app building guidance...
« Reply #8 on: September 18, 2011, 11:14:17 am »
Nice work Garrett, very clean.  Any idea of how you're going to release it?

Offline radarengineer

  • Sr. Member
  • ****
  • Posts: 402
  • Karma: +4/-0
Re: Android app building guidance...
« Reply #9 on: September 18, 2011, 11:21:24 am »
I agree with @guessed, the UI looks really nice. I'm sure there will be a lot of interest!

Offline mysticjay

  • Full Member
  • ***
  • Posts: 184
  • Karma: +1/-1
Re: Android app building guidance...
« Reply #10 on: September 18, 2011, 08:43:45 pm »
@Garrett
This is just FYI (in case you prefer C# and have experience with it)

http://android.xamarin.com/
Vera 2 (1.1.1338), Trane TZEMT400BB3,ML IWD600S(2), ML IWS1000S(2) , FI8905W, Aeon DSB04100-ZWUS, GE 45609(2), GE 45606(2), GE 45608, GE 45614 (5), LFM-20(2), Kwikset 99100-011 (5) , Hawking HRMD1, Droid X and Xoom as Remotes, Harmony Link

Offline mysticjay

  • Full Member
  • ***
  • Posts: 184
  • Karma: +1/-1
Re: Android app building guidance...
« Reply #11 on: September 18, 2011, 09:25:16 pm »
Looks nice Garret :)
Vera 2 (1.1.1338), Trane TZEMT400BB3,ML IWD600S(2), ML IWS1000S(2) , FI8905W, Aeon DSB04100-ZWUS, GE 45609(2), GE 45606(2), GE 45608, GE 45614 (5), LFM-20(2), Kwikset 99100-011 (5) , Hawking HRMD1, Droid X and Xoom as Remotes, Harmony Link

Offline mysticjay

  • Full Member
  • ***
  • Posts: 184
  • Karma: +1/-1
Re: Android app building guidance...
« Reply #12 on: September 24, 2011, 02:50:44 pm »
So I wanted to parse the User Data, preferably loadable as a .NET Dataset this is what I came up with. In case someone is doing the same thing :)

http://wiki.micasaverde.com/index.php/Parsing_Vera_User_Data_-_Loadable_as_.NET_Dataset
Vera 2 (1.1.1338), Trane TZEMT400BB3,ML IWD600S(2), ML IWS1000S(2) , FI8905W, Aeon DSB04100-ZWUS, GE 45609(2), GE 45606(2), GE 45608, GE 45614 (5), LFM-20(2), Kwikset 99100-011 (5) , Hawking HRMD1, Droid X and Xoom as Remotes, Harmony Link