We have moved at community.getvera.com

Author Topic: openLuup response to incorrect timer call  (Read 478 times)

Offline a-lurker

  • Hero Member
  • *****
  • Posts: 872
  • Karma: +66/-8
openLuup response to incorrect timer call
« on: April 14, 2017, 02:51:05 am »
Assume code is as follows:

Code: [Select]
luup.call_timer(Timer_End_Light_Garage, 1, '5m')
Timer_End_Light_Garage should be string not a function pointer. openLuup says:

Code: [Select]
openLuup.context_switch::  ERROR: ./openLuup/luup.lua:385: attempt to concatenate a function value
Could this be altered to say something along the lines of:

Code: [Select]
openLuup.context_switch::  ERROR: ./openLuup/luup.lua:385:  "function name 'Timer_End_Light_Garage' should be a string"

Offline akbooer

  • Moderator
  • Master Member
  • *****
  • Posts: 6387
  • Karma: +292/-70
  • "Less is more"
Re: openLuup response to incorrect timer call
« Reply #1 on: April 14, 2017, 06:02:51 am »
I've concentrated on getting the functionality of calls correct when used with the right parameters, rather than a fully comprehensive list of possible errors.  Extensive parameter checking would slow down the system by some amount.  But, along with a revamp of the error logging system, this is something which could be done better.

However, having made that mistake, you're never going to do it again, are you?   ;)
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: openLuup response to incorrect timer call
« Reply #2 on: April 16, 2017, 07:41:16 am »
The latest development branch update includes error checking for this (and also the new luup.ir.pronto_to_gc100() call.)

All luup functions which require text function names, rather than actual functions, use this. viz.
  • call_delay
  • call_timer
  • job_watch
  • register_handler
  • variable_watch

Instead of the previous obscure error at some point in the guts of openLuup, it now also reports the code line where the error occurred...

Code: [Select]
[string "ALTUI - LuaRunHandler"]:24: parameter #1 should be type string but is function
« Last Edit: April 17, 2017, 09:38:24 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.