Library / Shared documentation for control of Vera through UI Simple / JSON

I’ve been messing around off and on for quite some time with controlling Vera through UI Simple polling. The main issue I have is that the data that is returned from Vera seems to be a bit random. In particular, it seems that it is never clear what fields are going to be retruned from a certain device. It makes it a bit tough to map to SQL tables for instance!

I’ve been handling this by checking to see if fields I expect are in the JSON and if not storing empty values. As I can’t be sure what is going to be present in a JSON update for the devices I care about I typically push the new values to my table first and then process that device data from there.

As an example, “category” might not be a field in the update lu_sdata, and so if I have any logic that gets executed for a Binary Light I have to grab the Category for the updated device from initial data load to see if it is a Binary Light. I know that most of these fields aren’t supposed to change on a normal update, so this does make sense, except for the fact that it isn’t just changed fields that are pushed out.

The bottom line is that there is a lot to keep track of and I have had a few false starts. I think it would be useful to have this documented better so we don’t all have to recreate the wheel each time we work on a Vera client. Is there any interest in taking a stab at this as a community? For instance, figuring out how best to map JSON to SQL tables (or classes, etc) and then how to handle updated data. I think either better documentation or preferable an open source Vera library would be good. I am certainly happy to share anything I have. Right now it isn’t working quite right or I would have it posted already.

I’m attempting this with Python right now am experimenting with both SQL and Python classes to store the data. I would certainly be happy to try this with something else (Java?) instead.

The way I do it in my app is that I update the database using the device id as the lookup in the update command. The device id does not change. So when values change in the lu data, I update those values using the device id.

  • Garrett

Garrett, do you keep track of most of the data in the JSON, or just a few values? For example, for dimmable lights it looks like you only really need “state” and “level”.

Right now I’m caching everything I get just in case it ends up being useful later, but I’m not sure if that is the right approach.

I only really save what is needed. The I’d, name, state, level, category, room, and a few other values. When new data arrives, I just update those values.

  • Garrett

Garrett, thank you very much for the help! This morning I finally cleaned up my code to a point where I felt like I could release it. It is located here:

I am using this code in a plugin for EventGhost, but it is general enough that it could be used in any Python program. I have examples there of using it with both the Asyncore and Twisted python Eventloops. For anyone interested in using it with Eventghost: