We have moved at community.getvera.com

Author Topic: Detect openLuup  (Read 1624 times)

Offline vosmont

  • Beta Testers
  • Hero Member
  • *****
  • Posts: 687
  • Karma: +60/-8
Detect openLuup
« on: November 02, 2015, 05:14:21 pm »
Is there a way for a plugin to know if it is executed on openLuup ?

It seems that there is no special information in luup namespace.

Offline akbooer

  • Moderator
  • Master Member
  • *****
  • Posts: 6387
  • Karma: +291/-70
  • "Less is more"
Re: Detect openLuup
« Reply #1 on: November 02, 2015, 05:22:52 pm »
The whole point, of course, is that it doesn't.

As I mentioned in the release announcement for 5.5

The philosophy here is that openLuup itself should remain as true as possible* to standard Vera functionality.  That way we can ensure that most plugins written for Vera run also under openLuup.

(* with the notable exceptions of: not crashing, not running out of memory, and not using much CPU.)

In fact, it's incredibly easy to tell... but what for?

I did originally write VeraBridge to run on a standard Vera, and the old version should do just that.  However the new one, and obviously the openLuupExtensions plugin are specifically written for openLuup - but only because they have to be.   Almost by definition, they add functionality that is not there in the original.

Again,
Quote
HOWEVER...  now having gained the freedom to make improvements, the Extensions plugin is going to add extra facilities over time.

What's your plan?

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: +291/-70
  • "Less is more"
Re: Detect openLuup
« Reply #2 on: November 02, 2015, 05:41:47 pm »
Some basic differences can be seen by running this code in Lua Test

Code: [Select]
print (luup.attr_get "PK_AccessPoint")
print (luup.attr_get "BuildVersion")
print (luup.version_minor)

which gives these answers

Code: [Select]
88800127
*1.7.0*
0

which are all different from those which you would get from a real 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 vosmont

  • Beta Testers
  • Hero Member
  • *****
  • Posts: 687
  • Karma: +60/-8
Re: Detect openLuup
« Reply #3 on: November 03, 2015, 02:35:17 am »
OK, I will try.
It's because one of my plugin decompress lzo files (which do not exist on openLuup).

Offline akbooer

  • Moderator
  • Master Member
  • *****
  • Posts: 6387
  • Karma: +291/-70
  • "Less is more"
Re: Detect openLuup
« Reply #4 on: November 03, 2015, 02:45:23 am »
Ah yes, a number do try that.

Best approach is to code so that a decompression failure is not fatal and then just continue with the decompressed file, which should be there already.

Or perhaps even better, install a dummy pluto-lzo which does nothing, that way, nothing changes in the plugin.
« Last Edit: November 03, 2015, 02:49:05 am 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 vosmont

  • Beta Testers
  • Hero Member
  • *****
  • Posts: 687
  • Karma: +60/-8
Re: Detect openLuup
« Reply #5 on: November 03, 2015, 03:37:19 am »
Best approach is to code so that a decompression failure is not fatal and then just continue with the decompressed file, which should be there already.
I will try that... but I look for the troubles by accumulating the difficulties (test a plugin on Windows and ZeroBraneStudio)

Offline akbooer

  • Moderator
  • Master Member
  • *****
  • Posts: 6387
  • Karma: +291/-70
  • "Less is more"
Re: Detect openLuup
« Reply #6 on: November 03, 2015, 03:42:49 am »
The biggest problems are caused by os.execute for utilities that are not there in a Windows machine.

Best practice would be to use Lua equivalents where possible, for example os.remove rather than spawning rm, or also use the Lua File System library through
Code: [Select]
lfs = require "lfs"
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 vosmont

  • Beta Testers
  • Hero Member
  • *****
  • Posts: 687
  • Karma: +60/-8
Re: Detect openLuup
« Reply #7 on: November 03, 2015, 03:09:48 pm »
It works with LFS

Code: [Select]
local lfs = require("lfs")
if lfs.attributes("/etc/cmh-ludl/" .. fileName .. ".lzo", "mode") then
-- Do something
end
« Last Edit: November 03, 2015, 06:15:05 pm by vosmont »