We have moved at community.getvera.com

Author Topic: Porting Gcal3 to openluup  (Read 348 times)

Offline Stuart

  • Beta Testers
  • Hero Member
  • *****
  • Posts: 728
  • Karma: +71/-2
Porting Gcal3 to openluup
« on: September 21, 2018, 08:55:15 am »
A couple of years ago I was going to make an openluup specific port of GCal3 and then got distracted ....
GCal3, over the past year or so, has been not needed code changes.  Recently google made a change that needed an immediate fix  ....  Fortunately it was easy enough to identify so I issues a quick patch file.

A couple of folks using openluup picked up the patch file - functionally working but a UI problem - like no UI :-(

So I'm reinvigorated to take a look at openluup - but am traveling over the next few weeks and cannot get physically to my server to install etc. .

One question (for now) to maybe solve the UI problem.  In the patched file (nothing to do with the google issue) just from a more recent GCal version - I have this code:

    if ( luup.version_branch == 1 and luup.version_major == 7 and GCV.UI7Check == "false") then
        GCV.UI7Check = "true"
        luup.attr_set("device_json", "D_GCal3_UI7.json", lul_device)

(Yes - I know the if looks strange)

Several questiions:
1)  Do the luup.version and luup.version_major variables have meaning / return particular values in openluup ?
2)  If no - is there a simple way to tell if the code is running on openluup?
3) Does the line luup.attr_set("device_json" ....   do anything in openluup?
 

Offline reneboer

  • Beta Testers
  • Hero Member
  • *****
  • Posts: 1574
  • Karma: +110/-31
Re: Porting Gcal3 to openluup
« Reply #1 on: September 21, 2018, 12:39:23 pm »
Hi,

akbooer sure added a quick reliable check to see if you are running on openLuup. I use this bit of code to determine what a plugin is running on (part of a library of utils i compiled):
Code: [Select]
local _UI5 = 5
local _UI6 = 6
local _UI7 = 7
local _UI8 = 8
local _OpenLuup = 99

-- See what system we are running on, some Vera or OpenLuup
local function _getui()
if (luup.attr_get("openLuup",0) ~= nil) then
return _OpenLuup
else
return luup.version_major
end
return _UI7
end

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

Offline akbooer

  • Moderator
  • Master Member
  • *****
  • Posts: 6387
  • Karma: +292/-70
  • "Less is more"
Re: Porting Gcal3 to openluup
« Reply #2 on: September 21, 2018, 03:21:39 pm »
So I'm reinvigorated to take a look at openluup

That's great news!

Quote
1)  Do the luup.version and luup.version_major variables have meaning / return particular values in openluup ?

No, it's always 7.00.  It emulates UI7 luup calls.

Quote
2)  If no - is there a simple way to tell if the code is running on openluup?

Yes.  There's a variable luup.openLuup which is non-nil (actually, a table) in openLuup.  So you can write

Code: [Select]
if luup.openLuup then
  -- we're running under openLuup
end

Quote
3) Does the line luup.attr_set("device_json" ....   do anything in openluup?

...er, yes, I hope.  It sets that device attribute.
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 Stuart

  • Beta Testers
  • Hero Member
  • *****
  • Posts: 728
  • Karma: +71/-2
Re: Porting Gcal3 to openluup
« Reply #3 on: September 22, 2018, 07:56:36 pm »
Thanks guys. I have made some fairly small changes to the current, latest GCal code base and it looks like it will no longer cause issues in openLuup.  With that said - I will now look at putting this code into Alt App Store.

One question I have - does openlup pull all the files from the github folder or just those that it expects to be "plugin related".   I'm assuming and hoping the former.   The reason I'm asking is that I'm thinking of including the test calendar id and the test credentials file as part of the initial install setup.  So it would be nice if the install from github, by default, pulled the credentials file as well as the plugin files.

Offline akbooer

  • Moderator
  • Master Member
  • *****
  • Posts: 6387
  • Karma: +292/-70
  • "Less is more"
Re: Porting Gcal3 to openluup
« Reply #4 on: September 23, 2018, 06:52:27 am »
One question I have - does openlup pull all the files from the github folder or just those that it expects to be "plugin related".   I'm assuming and hoping the former.   The reason I'm asking is that I'm thinking of including the test calendar id and the test credentials file as part of the initial install setup.  So it would be nice if the install from github, by default, pulled the credentials file as well as the plugin files.

This is an AltAppStore thing, rather than specifically an openLuup one.  See the instruction here:

http://forum.micasaverde.com/index.php/topic,38102.msg284743.html#msg284743

In particular, judicious use of the Folder and Pattern fields can get you close to what you want.  If you've named files in the usual way, then a pattern of "[DIJLS]_%w+%.%w+" should work just fine.
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 Stuart

  • Beta Testers
  • Hero Member
  • *****
  • Posts: 728
  • Karma: +71/-2
Re: Porting Gcal3 to openluup
« Reply #5 on: September 23, 2018, 07:00:59 am »

In particular, judicious use of the Folder and Pattern fields can get you close to what you want.  If you've named files in the usual way, then a pattern of "[DIJLS]_%w+%.%w+" should work just fine.

Thanks. This will get me on the right track.

I just installed an openluup / AltUI instance on my Mac and can get it sorted out and tested while I?m on the road.