Anyone know if any of the 3rd party client apps (e.g. AutHomationHD, etc) are open source? Just want to get an idea how they interface with the VERA to see how feasible an idea I have is.
Unfortunately none of them are. But many of the developers on here are more than willing to help and answer your questions.
- Garrett
I do not think anyone has done open source …
I will be releasing my JavaScript interface soon … When I get a chance to get back to it:
See:
http://forum.micasaverde.com/index.php/topic,16104.msg122815.html#msg122815
The Main IO Part is included here:
// Class Factory
function VeraLoop() {
this.Url = "http://127.0.0.1:8003";
}
// Class
VeraLoop.prototype = {
Url: "",
FetchUserData: true,
DataVersion: 0,
StatusDataVersion: 0,
LoadTime: 0,
Data: null,
ReadyCB: null,
Ready: function(cb) {
if (! this.ReadyCB) {
this.ReadyCB = $.Callbacks();
}
this.ReadyCB.add(cb);
},
Sync: function() {
var cmd;
var t = this;
if (this.FetchUserData) {
cmd = "user_data2";
this.FetchData(
cmd,
function(data) {
t.FetchUserData = false;
t.Data = data;
t.StatusDataVersion = t.DataVersion = data.DataVersion;
t.LoadTime = data.LoadTime;
if (t.ReadyCB) {
t.ReadyCB.fire();
}
t.QueRequest(false);
},
function(jqXHR, textStatus, errorThrown) {
t.QueRequest(true);
});
} else {
cmd = "lu_status2&DataVersion=" + this.StatusDataVersion + "&LoadTime=" + this.LoadTime + "&Timeout=60&MinimumDelay=100";
this.FetchData(
cmd,
function(data) {
t.StatusDataVersion = data.DataVersion;
if (data.UserData_DataVersion != t.DataVersion) {
t.FetchUserData = true;
} else {
t.ParseLuStatus(data);
}
t.QueRequest(false);
},
function(jqXHR, textStatus, errorThrown) {
t.QueRequest(true);
});
},
},
FetchData: function(cmd, cb, errorcb) {
var url = this.Url + "/port_3480/data_request?output_format=json&id=" + cmd;
$.ajax({
dataType: "json",
url: url,
success: cb,
error: errorcb,
}
);
},
QueRequest: function(error) {
var t = this;
var to = 1000;
setTimeout(function() {t.Sync();}, to);
},
...
Action: function(service, action, args, id) {
var cmd = "lu_action&DeviceNum=" + id + "&serviceId=" + service + "&action=" + action;
for (var p in args) {
cmd += ("&" + p + "=" + args[p]);
}
this.FetchData(cmd, function(data) {}, function(jqXHR, textStatus, errorThrown) {});
}
};
// The following runs when the Javascript is parsed
(function(window, undefined) {
var jVera = new VeraLoop();
window.$V = jVera;
})(window);
// The following runs when the document is ready
$(function() {
$V.QueRequest(false);
})
The majority of the time the code is sitting in FetchData with an argument of lu_status2 where it is waiting for some event to happen on Vera.
The Action class method is where widgets invoke actions on Vera.
I left out the ParseLuStatus class method … this is where you would look for data in the returned JSON object and merge with data returned from user_data2 … all of which is very implementation specific.
If I understand the API correctly the URL could be replaced with the mios address for true remote access without requiring any additional changes?
Correct instead of using the ip and port of vera locally, you would substitute it with the mios username, password and vera id. Everything that follows after that is the same.
Local:
http://veraip:3480/data_requestid=lu_status2&output_format=json
Remote:
https://fwdXX.mios.com/miosUser/miosPassword/veraId/data_requestid=lu_status2&output_format=json
- Garrett
Interesting in the JS code above it seems to connect to port 8003. Perhaps that was some type of proxy.
It was a proxy … It allowed me to run this on a mobile phone or desktop …
using port forwarding.
It is also because of cross site scripting issues restrictions …
If you code this in Java, C#, Objective C, Perl, Python, … you will not have these issues.
That coupled with @Garrattwp comments for local vs remote will show you how this works on your LAN or remotely connected on a mobile device.
This example is event driven … It starts with a call to QueRequest … and … when this returns, either successfully or an error … it ultimately calls QueRequest again.
See:
http://wiki.micasaverde.com/index.php/UI_Notes#Building_a_control-only_UI_for_Vera
What I have not discussed is the format of the returned data. You will just have to roll up your sleeves and dig in …
You can issue the following call to get a feel for the data:
http://Your.Vera.IP.Address:3480/data_request?id=user_data
You can run the results through a web based JSON pretty printer if you do not have a development environment to easily review the data structure.
in firefox there are this plugins for making stuff easy.
-XML viewer 0.2b https://addons.mozilla.org/En-us/firefox/addon/xmlviewer/?src=ss
-Extended Statusbar 1.5.8 https://addons.mozilla.org/En-us/firefox/addon/extended-statusbar/
So I have been playing with a vera client also. I am open to an open source concept for those that want to work together. I made a very simple web page that got the complete json data set, parsed it and displayed the list of devices with a simple toggle button to turn lights on/off, or view if it was a camera. I put it in a loop that updated every second and it worked well and seemed responsive and updated quickly.
Of course, that could be a lot of network traffic when the client is open, so I then wanted to expand it to do the long polling technique with the timeout and delay, etc. Since this doesn't return the entire set of devices, I realized quickly this would require a lot more work to store the devices locally, change states, etc. hmmm, a lot of work for honestly seemingly little payoff (not really, but for arguments sake)
So I then decided to ssh into Vera and try to copy the web files and modify to what I want since MIOS is supposedly skinnable. I found some of the css files and could do some simple mods but when I was in the CGI directly I was surprised to NOT see a data_request file. So I started a search for it. nothing... where is that? Anyone know? Since it seems to be the first step with the requests, I think it would be important to start there to reverse engineer this.
The UI is ok and a web client is ok for me. There are just some annoying things I would like to fix for my use and preference.
So I am open to a few ideas... I am willing to work on a open source project with others. But does anyone know how the "data_request?" is actually processed on the server? As anyone thought about make a skin for vera and run directly on Vera?
since the vera UI runs on the vera itself it would be awkward to make it use a http request. it probably uses a piped connection or something similar.
im going to make my Yu Vera remote open source some day when i finished making the basic interface and theme system. you might want to look at that when i put it on github. i have no idea when i finish it as it takes a huge amount of time and a lot of code and i do this in my spare time which i dont have that much alas.
hmmm, if it used a socket then that would be more interesting to reverse engineer. I could then make a web client that used web sockets back to a php program (or other language) that made a socket connection to Vera. This would seriously reduce network traffic and processing overhead.
But my point on running it on Vera itself is to do it however it is done none but with a custom interface uniquely designed for the end user. So I don’t want to reinvent the wheel on what the onboard engine is doing, just change the presentation. Users could make there own skins and share them. We can choose what we like ![]()
If anyone has more information on how vera works server side, please share. I am still looking for how “data_request?” is handled / processed.
there is a project that involves installing php and a custom made website on vera itself. might wanna look at that. http://forum.micasaverde.com/index.php/topic,13133.0.html
I have uploaded my .NET Library for Vera to Codeplex. It is under The MIT License. This library may give you an idea on how to communicate with Vera.
Ercant. Thank you for doing this. More people need to do open source projects like yours.