This page last changed on Apr 08, 2013 by juha.

In the OR newsletter I got today is an article "Give your Vera a new dimension":

"[...] Vera could already be controlled by OpenRemote thanks to it's http commands and XML status file. Howevere, working with Marcus we managed to have a really responsive and load less protocol. Now, your OpenRemote designs are as responsive as the original MicasaVerde user interface! [...]"

I know the Howto http://www.openremote.org/display/docs/OpenRemote+2.0+How+To+-+Micasaverde+Vera but where can I find more information about this new protocol?

Best regards
Daniel

The how to is all that exists at this moment. What type of information are you looking for?

Posted by juha at Apr 08, 2013 13:29

Oh, I thought this howto was the "old" one and there is now a more "load less protocol" with even more "responsiveness"

Regarding the howto I wonder why the status requests from vera are in xml format and not json as recommended by Micasaverde to save vera ressources?

I wrote a a simple php-wrapper based on jsonpath, if someone is interested:

<?php
require_once('JSON.php');
require_once('jsonpath.php');
require_once('_config.php');

$d = $_GET["d"];  # d = device
$c = $_GET["c"];  # c = command

switch ($c) {

# o(n)
case "n":
$res = http_get("http://$vera_ip:3480/data_request?id=lu_action&output_format=json&DeviceNum=$d&serviceId=urn:upnp-org:serviceId:SwitchPower1&action=SetTarget&newTargetValue=1", array("timeout"=>5));
break;

# o(f)f
case "f":
$res = http_get("http://$vera_ip:3480/data_request?id=lu_action&output_format=json&DeviceNum=$d&serviceId=urn:upnp-org:serviceId:SwitchPower1&action=SetTarget&newTargetValue=0", array("timeout"=>5));
break;

# s(t)atus
case "t":
$statusfile=fopen("status.json","r");
$status=fgets($statusfile);
$parser = new Services_JSON(SERVICES_JSON_LOOSE_TYPE);
$o = $parser->decode($status);
$devicestatus = jsonPath($o, "$.devices[?(@['id']==$d)].status");
$status = $devicestatus[0];
if ($status == 0) { echo "off"; } else { echo "on"; };
fclose($statusfile);
break;

# s(c)ene
case "c":
$res = http_get("http://$vera_ip:3480/data_request?id=lu_action&serviceId=urn:micasaverde-com:serviceId:HomeAutomationGateway1&action=RunScene&SceneNum=$d", array("timeout"=>5));
break;

}

?>
Posted by emster at Apr 08, 2013 13:40

I think the difference was that the state is fetched with a single request for all devices/sensors, rather than individually for each sensor as it was before.

But no there's no bidirectional "push" from Vera to OpenRemote. I don't recall the discussions earlier if Vera supports broadcasting such sensor states actively rather than forcing a polling method to be used?

Thanks for posting your script btw, appreciated. Noted it down, will try to find a place for it somewhere in the wiki once I have time.

Posted by juha at Apr 08, 2013 13:53

If you want to place my script in a wiki, here is the corresponding get-status.php which runs on the webserver to get the sensor status from vera every second.

To further minimize the status-polling between OR controller and webserver I tried with shell execution protocol like here http://www.openremote.org/display/forums/Velleman+K8055+Experiment+USB+board?focusedCommentId=19440410#comment-19440410
but doesn't work for me. Get always the Error:

2013-04-08 15:17:38,001 ERROR [Controller Definition File Watcher for Default Deployer]: Creating sensor failed. Error : 
The included command reference in a sensor (ID = 183) is not an event producer (Command id : 183, Type : 162)
# get-status.php
#!/usr/bin/php

<?php
require_once('_config.php');

$statusfile = fopen("status.json","w");
while (1) {
    $res = http_get("http://$vera_ip:3480/data_request?id=lu_sdata");
    list($header, $html) = explode("\r\n\r\n", $res);
    rewind($statusfile);
    ftruncate($statusfile, 0);
    fwrite($statusfile, $html);
    fflush($statusfile);
    usleep(1000000);
}
fclose($statusfile);

?>
Posted by emster at Apr 08, 2013 14:31

The How-To does not describe the new version which was mentioned in the newsletter.
Erwan is looking to make it availabe to a bigger test community.
I will give him a ping to look at this forum thread.

Posted by mredeker at Apr 09, 2013 09:28

Any news here? Who and where is Erwan?

Posted by emster at Apr 13, 2013 09:14
Document generated by Confluence on Jun 05, 2016 09:42