I know Akbooer is working on an upgrade to the VeraBridge plugin that could include a similar feature (and most probably much more sophisticated than mine…), but I felt it could be useful in the meantime to share what I implemented on my openLuup and companion Vera…
The rationale for this is two fold:
1 - enable the piece of my logic on the real Vera that I could not yet migrate to openLuup to obtain data from the other pieces that I have moved to openLuup
2 - enable “out of the box” read of some variables that reside on the openLuup system from the remote apps I use to connect to the Vera (e.g. HomeWave) through the MiOS relays. Since my Vera system is in a vacation home, easy remote access is paramount (a VPN needs to be started/disconnected in addition to launching the app or the browser… Same for weaved.com that needs a user/password input in a browser)
Here is the “how-to”… it is long and a bit complex so it is not for the faint hearted !
Important: the below instructions are used at your own risk and assume you know what you are doing… Some of these changes may render either your Vera or your openLuup system unusable.
A) on the real Vera:
1) create the dummy device(s) that will be the mirror(s) and host the mirrored variables
the easiest method is to use the “create device” option in the AltUI “Devices” menu: you wil be presented 3 input boxes. Only the first two should be filled (we are creating dummy devices, so we do not want/need to register an I_xxx.xml implementation file). For instance:
Device Name: Temperature Mirror
D_xxx.xml filename: D_TemperatureSensor1.xml
and click the “Save Changes” button. After AltUI creates the device(s) (you might need to refresh your brower), please make note of the device id(s) of your newly created device(s) as you will need that for the followin steps. You can later rename or move the devices into specific rooms as you wish.
2) for each of the newly created devices, set a new attribute “openLuup_Ignore” that MUST be set before proceeding further.
Failure to set that attribute will result in a race condition and may make your openLuup system unusable !!!
to do this, run the below code in the AltUI “Lua Test Code” window, replacing deviceid by the relevant device id you obtained in 1) above:
luup.attr_set("openLuup_Ignore", "1", deviceid)
B) on the openLuup system:
1) modify the VeraBridge plugin to instruct it NOT to replicate in openLuup the mirror devices we created on the Vera
Using the tool of your choice (e.g. WinSCP):
a) make a backup of the “L_VeraBridge.lua” file, so that you can undo any mistake later if needed
b) edit the following line of code (it is line 88 in the version of VeraBridge I am using):
if not (dev.invisible == "1") then
to become:
if not ((dev.invisible == "1") or (dev.openLuup_Ignore == "1")) then
then save the modified file AND reload openLuup
2) add the following code in either your startup Lua code or (much easier since for now editing lua startup code on openLuup is not very easy) into a lua module that is called on startup… See http://forum.micasaverde.com/index.php/topic,34468.msg254013.html#msg254013
[code]–[[
This code is meant to push certain watched variables on an openLuup system to “mirror” devices on a real Vera
Written by “logread” - free software provided “as is” and to be used at your own risk
Pre-requisite: appropriate mirror devices properly set up on a real Vera, as per separate instructions (including
modified “VeraBridge” plugin and the setup of a new device attribute “openLuup_Ignore” to avoid race conditions
–]]
– USER PARAMETERS: MUST BE EDITED AS APPROPRIATE
local VeraIP = “192.168.99.99” – this is the IP of the Vera on which the mirror device(s) reside
– should be same as in the relevant “VeraBridge” device
local watches = {}
watches[1] = {“urn:upnp-org:serviceId:TemperatureSensor1”, “CurrentTemperature”, 15, 82 }
watches[2] = {“urn:micasaverse-com:serviceId:HumiditySensor1”, “CurrentLevel”, 16, 83 }
watches[3] = {“urn:cd-jackson-com:serviceId:SystemMonitor”, “memoryAvailable”, 17, 85}
watches[4] = {“urn:cd-jackson-com:serviceId:SystemMonitor”, “systemLuupRestartTime”, 17, 85}
–[[ note to the above watches table: for each variable to be mirrored, it needs to include an entry like:
watches[#] = {, , ,}
–]]
– END OF USER PARAMETERS
local http = require(“socket.http”)
local ModuleName = "pushtomirror: "
function url_encode(str) – we need this as some variables to be sent via http might not be compliant with url encoding
if (str) then
str = string.gsub (str, “\n”, “\r\n”)
str = string.gsub (str, “([^%w %-%_%.%~])”,
function (c) return string.format (“%%%02X”, string.byte(c)) end)
str = string.gsub (str, " ", “%%20”)
end
return str
end
function watchvariable(lul_device, lul_service, lul_variable, lul_value_old, lul_value_new)
local mirrordevice = 9999 – fancy device number to avoid lua error if mirrordevice cannot be found
for k in pairs(watches) do
if ((watches[k][1] == lul_service) and (watches[k][2] == lul_variable) and (watches[k][3] == lul_device)) then
mirrordevice = watches[k][4] end
end
local url = “http://” … VeraIP … “:3480/data_request?id=variableset&DeviceNum=” … mirrordevice
url = url … “&serviceId=” … lul_service … “&Variable=” … lul_variable … “&Value=” … url_encode(lul_value_new)
luup.log(ModuleName … "calling " … url) – for debug
local returndata, retcode = http.request(url)
if returndata == nil then returndata = “” end – avoid a crash in logging returndata if error in request
luup.log(ModuleName … retcode … " " … returndata) – for debug
local err = (retcode ~=200)
if err then – something wrong happpened (Vera down, bad parameters)
luup.log(ModuleName … "bad response from Vera " … VeraIP) – for debug
else
luup.log(ModuleName … "good response from Vera " … VeraIP) – for debug
end
end
function watchesregister() – setup the watches
for k in pairs(watches) do
luup.variable_watch(“watchvariable”, watches[k][1], watches[k][2], watches[k][3])
end
end
– register call back functions in the Lua global environment
_G[“watchvariable”] = watchvariable
_G[“watchesregister”] = watchesregister
luup.call_delay(“watchesregister”, 60) – wait 60 seconds so that openLuup finishes its initialization sequence
[/code]
and reload openLuup
This has been tested with my openWeather and openSysMon plugins and 3 target mirror devices on the Vera.