We have moved at community.getvera.com

Author Topic: how-to: mirroring select openLuup devices/variables on real Vera  (Read 7174 times)

Offline akbooer

  • Moderator
  • Master Member
  • *****
  • Posts: 6387
  • Karma: +292/-70
  • "Less is more"
Re: how-to: mirroring select openLuup devices/variables on real Vera
« Reply #15 on: May 14, 2016, 08:40:26 am »
I've updated the development branch VeraBridge to implement exactly this functionality.
3x Vera Lite-UI5/Edge-UI7, 25x Fibaro, 23x TKB, 9x MiniMote, 2x NorthQ Power, 2x Netatmo, 1x Foscam FI9831P, 9x Philips Hue,
Razberry, MySensors Arduino, HomeWave, AltUI, AltHue, DataYours, Grafana, openLuup, ZWay, ZeroBrane Studio.

Offline logread

  • Full Member
  • ***
  • Posts: 214
  • Karma: +7/-1
Re: how-to: mirroring select openLuup devices/variables on real Vera
« Reply #16 on: May 14, 2016, 09:10:07 am »
Great. I'll try this out over the week-end on my test VM !
Vera Lite UI7, Fibaro FGS-221, FGS-212, FGSS-001, FGK-101, FGWPE/F-101, FGMS-001, Aeon HEM G2, GreenWave PowerNode 6,  Everspring ST-814, SE-812, Swiid SwiidInter.
Raspberry Pi2 Raspbian w/ openLuup. AltUI, SV Thermostat, Virtual Switch, Weather (openWeather), System Monitor (openSysMon), HomeWave.

Offline logread

  • Full Member
  • ***
  • Posts: 214
  • Karma: +7/-1
Re: how-to: mirroring select openLuup devices/variables on real Vera
« Reply #17 on: May 15, 2016, 06:12:09 am »
@Akbooer,

Upgraded my test system to openLuup 8RC without any issue... And mirroring works just great ! Many thanks...

My only pending issue is the syncing of house modes, but that's for another thread
Vera Lite UI7, Fibaro FGS-221, FGS-212, FGSS-001, FGK-101, FGWPE/F-101, FGMS-001, Aeon HEM G2, GreenWave PowerNode 6,  Everspring ST-814, SE-812, Swiid SwiidInter.
Raspberry Pi2 Raspbian w/ openLuup. AltUI, SV Thermostat, Virtual Switch, Weather (openWeather), System Monitor (openSysMon), HomeWave.

Offline pls90

  • Sr. Member
  • ****
  • Posts: 314
  • Karma: +2/-0
Re: how-to: mirroring select openLuup devices/variables on real Vera
« Reply #18 on: July 22, 2016, 05:37:32 pm »
now that I have running some plugins on my verabridge I would like to start offloading those plugins from vera. As I still need pleg I wonder how I will be able create a device property in pleg that refers to a device or variable on the verabridge. I readthrough the above posts a couple of times but I am still unsure wether I have to setup dummy devices on vera which then will be filled by the values from the verabridge or if there is a more elegant way to do this.
The user guide from github (dev branch) states that mirroring requires editing of the startup.lua
Code: [Select]
-- Mirrors syntax:
-- <VeraIP>
-- <Vera deviceId> = <openLuup deviceId>.<serviceId of the variable>.<variable
name>
-- ...
luup.attr_set ("openLuup.mirrors", [[
192.168.99.99
82 = 15.urn:upnp-org:serviceId:TemperatureSensor1.CurrentTemperature
83 = 16.urn:micasaverse-com:serviceId:HumiditySensor1.CurrentLevel
85 = 17.urn:cd-jackson-com:serviceId:SystemMonitor.memoryAvailable
85 = 17.urn:cd-jackson-com:serviceId:SystemMonitor.systemLuupRestartTime
]])
Is this the way to go?
Could you please explain if I have to manually create dummy devices on vera?

Offline akbooer

  • Moderator
  • Master Member
  • *****
  • Posts: 6387
  • Karma: +292/-70
  • "Less is more"
Re: how-to: mirroring select openLuup devices/variables on real Vera
« Reply #19 on: July 22, 2016, 05:49:24 pm »
The user guide from github (dev branch) states that mirroring requires editing of the startup.lua
[...]
Is this the way to go?

Yes and No...  it's not a startup.lua file which is involved, but the Startup Lua code on the Misc AltUI pages.  The manual is up to date, and since AltUI enables direct editing of the Startup code, then this is very easy to do.  When you save an edit to the startup code, you can safely ignore the AltUI warning that there will be a reload - Vera needs this, but openLuup does not.

Quote
Could you please explain if I have to manually create dummy devices on vera?

Yes, there was lots of angst about the best way to do this during the design process.  In the end, I abandoned any thought of creating a dummy device automatically from openLuup: it would have caused a Vera reload, at the very least (and, goodness knows, Vera does that enough already.)  So you really have two choices:
  • create a dummy device, manually on Vera (easiest through the AltUI interface) it doesn't need an implementation file, just a device file (although if you did this directly from luup.create_device() you could get away with just a device type which doesn't even have to exist)
  • use an existing device, if it makes sense and doesn't conflict with any existing device variable.
At the moment, the mirrored variable has the same name and serviceId as the local openLuup one, but I'm thinking of extending the syntax in the Startup code to allow you to specify something different.
3x Vera Lite-UI5/Edge-UI7, 25x Fibaro, 23x TKB, 9x MiniMote, 2x NorthQ Power, 2x Netatmo, 1x Foscam FI9831P, 9x Philips Hue,
Razberry, MySensors Arduino, HomeWave, AltUI, AltHue, DataYours, Grafana, openLuup, ZWay, ZeroBrane Studio.

Offline pls90

  • Sr. Member
  • ****
  • Posts: 314
  • Karma: +2/-0
Re: how-to: mirroring select openLuup devices/variables on real Vera
« Reply #20 on: July 23, 2016, 02:54:29 am »
Ok, I'll give it a try with my variables from heliotrope.
I agree that an automatic generation of dummy devices is far to complicated.
But how about this:
If the user had some kind of wizard on openluup that lets him pick the object on the verabridge wich he wants to mirror and then the wizard determines which device type and hence device file is needed and then creates the device on vera.
For example my use case would be:
I need the heliotrope variables 'azimuth'  and 'altitude' mirrored. So I would start the wizard, pick the 'heliotrope' from a list of all devices on verbridge and be presented with a list of all variables from 'heliotrope'. I then would check all variables needed. Finally clicking on 'generate devices' would create all needed devices on vera.
What do you think?

Offline pls90

  • Sr. Member
  • ****
  • Posts: 314
  • Karma: +2/-0
Re: how-to: mirroring select openLuup devices/variables on real Vera
« Reply #21 on: July 23, 2016, 09:36:43 am »
I'm not there yet.  :-[
I created a device on vera (GenericSensor, ID 287)
Then I tried to mirror that device to my Heltitrope device (ID 8) on openluup.

Code: [Select]
luup.attr_set ("openLuup.mirrors", [[
192.168.2.124
287 = 8.urn:futzle-com:serviceId:AstronomicalPosition_Sun.Azimuth360
]])

the result in the log showed no errors
Code: [Select]
2016-07-23 15:15:14.814   openLuup.server:: request completed (100361 bytes, 7 chunks, 3628 ms) tcp{client}: 0x2984618
2016-07-23 15:15:14.919   openLuup.server:: /data_request?id=lu_status2&output_format=json&DataVersion=279384509&Timeout=60&MinimumDelay=1500&_=1469278417325 tcp{client}: 0x2984618
2016-07-23 15:15:17.312   openLuup.server:: /data_request?id=lr_ALTUI_LuaRunHandler&command=run_lua&lua=luup.attr_set%20(%22openLuup.mirrors%22%2C%20%5B%5B%0A192.168.2.124%0A287%20%3D%208.urn%3Afutzle-com%3AserviceId%3AAstronomicalPosition_Sun.Azimuth360%0A%5D%5D)&_=1469278417326 tcp{client}: 0x206db28
2016-07-23 15:15:17.313   luup_log:0: ALTUI: runLua(luup.attr_set ("openLuup.mirrors", [[
192.168.2.124
287 = 8.urn:futzle-com:serviceId:AstronomicalPosition_Sun.Azimuth360
]]))
2016-07-23 15:15:17.313   luup_log:0: ALTUI: Evaluation of lua code returned: nil
2016-07-23 15:15:17.315   openLuup.server:: request completed (8 bytes, 1 chunks, 2 ms) tcp{client}: 0x206db28
2016-07-23 15:15:17.820   openLuup.server:: request completed (3117 bytes, 1 chunks, 2901 ms) tcp{client}: 0x2984618
2016-07-23 15:15:17.823   openLuup.server:: /data_request?id=user_data&output_format=json&DataVersion=279371946&_=1469278417327 tcp{client}: 0x2984618
2016-07-23 15:15:17.981   openLuup.server:: request completed (967832 bytes, 61 chunks, 157 ms) tcp{client}: 0x2984618
2016-07-23 15:15:20.023   openLuup.server:: /data_request?id=lu_status2&output_format=json&DataVersion=279384510&Timeout=60&MinimumDelay=1500&_=1469278417328 tcp{client}: 0x2984618
2016-07-23 15:15:21.626   openLuup.server:: request completed (4602 bytes, 1 chunks, 1603 ms) tcp{client}: 0x2984618
2016-07-23 15:15:21.733   openLuup.server:: /data_request?id=lu_status2&output_format=json&DataVersion=279384511&Timeout=60&MinimumDelay=1500&_=1469278417329 tcp{client}: 0x2984618
Alas, the 'virtual' device shows no Azimuth value.
Do the pair of devices on vera and openluup have to be of the same type?
Could I create a 'virtual' heliotrope on vera without implementation file that just holds the varaibles?
What I thought from your reply is that device types don't matter.

Offline akbooer

  • Moderator
  • Master Member
  • *****
  • Posts: 6387
  • Karma: +292/-70
  • "Less is more"
Re: how-to: mirroring select openLuup devices/variables on real Vera
« Reply #22 on: July 23, 2016, 10:37:18 am »
Is 192.168.2.124 the correct IP for your Vera?

I've just set this up on a system bridging to a Vera Edge.

Code: [Select]
luup.attr_set ("openLuup.mirrors", [[
172.16.42.14
33 = 162.urn:upnp-org:serviceId:TemperatureSensor1.CurrentTemperature
]])

You should see something like this in the startup log for the bridge:

Code: [Select]
2016-07-23 14:29:54.584   luup.variable_watch:169: callback=VeraBridge_Mirror_Callback, watching=162.urn:upnp-org:serviceId:TemperatureSensor1.CurrentTem\
perature

then when the watched variable changes...
Code: [Select]
2016-07-23 14:31:51.579   luup.variable_set:0: 162.urn:upnp-org:serviceId:TemperatureSensor1.CurrentTemperature was: 26.4 now: 26.5 #hooks:1
2016-07-23 14:31:51.580   openLuup.server:: request completed (2 bytes, 1 chunks, 1 ms) tcp{client}: 0x22eebb0
2016-07-23 14:31:51.580   luup.watch_callback:: 162.urn:upnp-org:serviceId:TemperatureSensor1.CurrentTemperature function: 0x1ea9f30

and, of course, you should see the variable on the remote Vera.
3x Vera Lite-UI5/Edge-UI7, 25x Fibaro, 23x TKB, 9x MiniMote, 2x NorthQ Power, 2x Netatmo, 1x Foscam FI9831P, 9x Philips Hue,
Razberry, MySensors Arduino, HomeWave, AltUI, AltHue, DataYours, Grafana, openLuup, ZWay, ZeroBrane Studio.

Offline pls90

  • Sr. Member
  • ****
  • Posts: 314
  • Karma: +2/-0
Re: how-to: mirroring select openLuup devices/variables on real Vera
« Reply #23 on: July 23, 2016, 11:09:44 am »
Quote
Is 192.168.2.124 the correct IP for your Vera?
Yes it is. Or do I have to add the port ':3480'?
Quote
and, of course, you should see the variable on the remote Vera.
I do. Atteached is how it looks from Vera and AltUI.

Interestingly I can't find a single entry in the log like
Code: [Select]
luup.variable_watchor
Code: [Select]
luup.watch_callbacI guess that is the root of the problem.

Where does this go?
Code: [Select]
luup.attr_set ("openLuup.mirrors", [[
172.16.42.14
33 = 162.urn:upnp-org:serviceId:TemperatureSensor1.CurrentTemperature
]])

I put mine in Misc > Lua Test Code > in the code window ans submitted it.
Should I have done that differently?

Offline akbooer

  • Moderator
  • Master Member
  • *****
  • Posts: 6387
  • Karma: +292/-70
  • "Less is more"
Re: how-to: mirroring select openLuup devices/variables on real Vera
« Reply #24 on: July 23, 2016, 12:00:54 pm »
Quote
I put mine in Misc > Lua Test Code > in the code window ans submitted it.
Should I have done that differently?

Yes, you should.  It goes in Misc > Lua Startup Code
3x Vera Lite-UI5/Edge-UI7, 25x Fibaro, 23x TKB, 9x MiniMote, 2x NorthQ Power, 2x Netatmo, 1x Foscam FI9831P, 9x Philips Hue,
Razberry, MySensors Arduino, HomeWave, AltUI, AltHue, DataYours, Grafana, openLuup, ZWay, ZeroBrane Studio.

Offline pls90

  • Sr. Member
  • ****
  • Posts: 314
  • Karma: +2/-0
Re: how-to: mirroring select openLuup devices/variables on real Vera
« Reply #25 on: July 23, 2016, 02:44:19 pm »
I did make a mistake, wrong vera IP  :-[
I changed that, put it in Misc > Luas startup Code, restartet, no luck.
The 'virtual' device on vera 'vbm_heliotrope_azimuth', it is still there showing "value".
What did change is the fact that the device 'vbm_heliotrope_azimuth' on verabridge vanished.
Any ideas what I could try?
Different device type? The device I created on vera has an implementation file. Does that matter?

Offline pls90

  • Sr. Member
  • ****
  • Posts: 314
  • Karma: +2/-0
Re: how-to: mirroring select openLuup devices/variables on real Vera
« Reply #26 on: July 23, 2016, 04:28:31 pm »
One step further!
The values from verabridge are actually pushed to virtual device on vera.
That only shows on the advanced tab of the device, whereas I was expecting to see the value on device itself which only showed 'value'.
I tried to get several to values into one device (Azimuth360 and Altitude).
Onyl after adding a new variable on the advanced tab of the virtual device on vera was the second value transferred.
Is mirroring function supposed to create the variable in the virtual device by itself?
Also, the values on the virtual device seem to be 'stuck' at times. When I refresh the browser (ctrl f5) the values are updated.
I wonder if this will affect pleg functioning correctly.
Anyhow, @akbooer, thank you so much for your never ending patience. You literally carried me to this point.
Hopefully I'll be able to make some steps on my own, soon. :)

Offline akbooer

  • Moderator
  • Master Member
  • *****
  • Posts: 6387
  • Karma: +292/-70
  • "Less is more"
Re: how-to: mirroring select openLuup devices/variables on real Vera
« Reply #27 on: July 23, 2016, 04:36:22 pm »
I did make a mistake, wrong vera IP  :-[

That's why I asked   ;)

Quote
I changed that, put it in Misc > Luas startup Code, restartet, no luck.

So what does the openLuup log show? That's what it's there for... So we don't have to guess what's going on.

Quote
The 'virtual' device on vera 'vbm_heliotrope_azimuth', it is still there showing "value".

Don't understand.  What 'value'? Where?

Quote
What did change is the fact that the device 'vbm_heliotrope_azimuth' on verabridge vanished.

How did you restart the system?  If you specify anything other than the previous user_data.json file (or nothing) then you start from scratch and wipe out previous devices.

Quote
Any ideas what I could try?
Different device type? The device I created on vera has an implementation file. Does that matter?

The device type is irrelevant, but you do not particularly want to have a running plugin, so best to go without an implementation file. 

It's hard to advise without the full picture.  The log is a very good start.
3x Vera Lite-UI5/Edge-UI7, 25x Fibaro, 23x TKB, 9x MiniMote, 2x NorthQ Power, 2x Netatmo, 1x Foscam FI9831P, 9x Philips Hue,
Razberry, MySensors Arduino, HomeWave, AltUI, AltHue, DataYours, Grafana, openLuup, ZWay, ZeroBrane Studio.

Offline akbooer

  • Moderator
  • Master Member
  • *****
  • Posts: 6387
  • Karma: +292/-70
  • "Less is more"
Re: how-to: mirroring select openLuup devices/variables on real Vera
« Reply #28 on: July 23, 2016, 04:44:40 pm »
One step further!
The values from verabridge are actually pushed to virtual device on vera.

Yes, that's the way it's supposed to work.

Quote
That only shows on the advanced tab of the device, whereas I was expecting to see the value on device itself which only showed 'value'.

What the device shows on its front panel is device dependent.  Temperature devices show temperature, humidity shows humidity, dimmers show brightness level...  this is nothing to do with what other device variables are around.

Quote
I tried to get several to values into one device (Azimuth360 and Altitude).
Onyl after adding a new variable on the advanced tab of the virtual device on vera was the second value transferred.

This, I somehow doubt.  But what IS true is that variables will only appear once they change value for the first time.  Thereafter they should change on every update.

Quote
Is mirroring function supposed to create the variable in the virtual device by itself?
Also, the values on the virtual device seem to be 'stuck' at times. When I refresh the browser (ctrl f5) the values are updated.

Yes, the mirror creates the variables, but see above for when that happens.

The visual update is purely a function of the UI, and for Vera that often means refreshing a page.  Are you not running AltUI on your Vera?

Quote
I wonder if this will affect pleg functioning correctly.

PLEG shouldn't be able to tell the difference between a native variable and one crested and updated by the mirror.

Quote
Anyhow, @akbooer, thank you so much for your never ending patience. You literally carried me to this point.
Hopefully I'll be able to make some steps on my own, soon. :)

You're welcome. Knowledge comes with time and perseverance.
« Last Edit: July 23, 2016, 04:46:39 pm by akbooer »
3x Vera Lite-UI5/Edge-UI7, 25x Fibaro, 23x TKB, 9x MiniMote, 2x NorthQ Power, 2x Netatmo, 1x Foscam FI9831P, 9x Philips Hue,
Razberry, MySensors Arduino, HomeWave, AltUI, AltHue, DataYours, Grafana, openLuup, ZWay, ZeroBrane Studio.

Offline reneboer

  • Beta Testers
  • Hero Member
  • *****
  • Posts: 1574
  • Karma: +110/-31
Re: how-to: mirroring select openLuup devices/variables on real Vera
« Reply #29 on: March 07, 2017, 04:51:06 am »
Hi akbooer,

Been a while on this topic, but I have two questions. Can I set the openLuup.Mirrors attribute in a plugin as well, or must it be in the startup code?

And is it dynamic, i.e. can I set it without a LUA reload?

I'm thinking about a plugin giving a GUI to set this rather then code it.

Cheers Rene
2xVeraLite, VeraEdge, openLuup, ALTUI, 20 switches, 10 dimmers, 20 sensors, 10 scene controllers, 1 Harmony Hub, many plug-ins. Not enough time.