We have moved at community.getvera.com

Author Topic: luup.call_timer documentation issues  (Read 267 times)

Offline reneboer

  • Beta Testers
  • Hero Member
  • *****
  • Posts: 1574
  • Karma: +110/-31
luup.call_timer documentation issues
« on: August 30, 2018, 08:03:52 am »
Hi,

I am unclear of how luup.call_timer type 2 should work. I thought that if  i specify days as "1,2,3,4,5,6,7" the timer fires each day of the week at the specified time. However it seems to run only once for the first day in the schedule. So should I repeat the call to luup.call_timer? The wiki say for the example of days="1,4" it will run on Monday or Thursday. Is that what ever is the first one, random, or what? It would think it will run each Monday and Thursday instead  :o

I.e. is this the proper way to run the function each day at 00:00:10 :
Code: [Select]
function myCallback()
   -- do my stuff
end

luup.call_timer("myCallback", 2, "00:00:10", "1,2,3,4,5,6,7")

or is this:
Code: [Select]
function myCallback()
  luup.call_timer("myCallback", 2, "00:00:10", "1,2,3,4,5,6,7")
   -- do my stuff
end

luup.call_timer("myCallback", 2, "00:00:10", "1,2,3,4,5,6,7")

The first only seem to run once.

Cheers Rene
« Last Edit: August 30, 2018, 08:07:50 am by reneboer »
2xVeraLite, VeraEdge, openLuup, ALTUI, 20 switches, 10 dimmers, 20 sensors, 10 scene controllers, 1 Harmony Hub, many plug-ins. Not enough time.

Offline rigpapa

  • Beta Testers
  • Hero Member
  • *****
  • Posts: 1121
  • Karma: +187/-3
Re: luup.call_timer documentation issues
« Reply #1 on: August 30, 2018, 08:32:15 am »
I use this very rarely (I tend to use call_delay), but what you are seeing is consistent with my experience--it will call the callback on the first matching date/time for the spec given. If you want repeated calls, you have to call it again, presumably with the same time spec if you want the same schedule.

For any Vera folks reading this, this is one of the calls/callbacks (along with call_delay) that I believe needs to have its callback interface extended to explicitly include the context device number, separate from the string parameter that can be passed. Yes, we can pass the device number in that string parameter, but when other arguments are needed by the callback, we have to resort to creating some in-string syntax that needs to be parsed/split. Or, we have to look at luup.device, which I believe should not exist (it is effectively a context-specific, transient global in an otherwise pure module context), or a global (to some scope) variable we've previously assigned to store the device number. Also, in the calls to call_delay and call_timer, it would be preferable to have the function argument be a function type (you could still handle a string as you currently do, just add function support), so that a named or anonymous function can be passed/used and we can potentially have access to upvalues in the callback. This would also resolve the issue of needing to have the callback function (when passed by name) be global so that Luup can find it. Keep stuff out of global context as much as possible!
Author of Reactor, DelayLight, SiteSensor, Rachio, Deus Ex Machina II, Intesis WMP Gateway, Auto Virtual Thermostat and VirtualSensor plugins. Vera Plus w/100+ Z-wave devices. Vera3, Lite. Hassio, Slapdash.

Offline akbooer

  • Beta Testers
  • Master Member
  • *****
  • Posts: 6387
  • Karma: +290/-70
  • "Less is more"
Re: luup.call_timer documentation issues
« Reply #2 on: August 30, 2018, 08:52:22 am »
Yes, this is a problem.  Scenes with these timers repeat, but luup calls do not.

In openLuup, I addressed this by adding an additional parameter to the timer call, set to true if repeated operation is required.

Just one of the many stunning inconsistencies in the luup interface.
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: luup.call_timer documentation issues
« Reply #3 on: August 30, 2018, 09:05:28 am »
Ok,

Thanks, so it is not me just going bonkers (again).

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