Well, for some strange reason I cannot get a luup.call_delay or a luup.timer to work within my plugin so that it routinely checks and if needed refreshes the IP address.
I’ve tried numerous things, the one I thought would work was the following…
Within the Lua (L_ExternalIP1.lua) file I have a function called refreshExternalIP(lul_device)
Within the Implementation (I_ExternalIP1.xml) file, I have declared a global function called NC_RefreshExtIP - see below…
function initialiseExternalIPPlugin(lul_device)
luup.log("ExternalIP: Plugin STARTING-UP!")
ExternalIP = require "L_ExternalIP1"
NC_RefreshMyExtIP = ExternalIP.refreshExternalIP
return ExternalIP.ExternalIPStartUp(lul_device)
end
Then at the end of the end of the refreshExternalIP(lul_device) function I added a luup.call delay to call the global name of that function.
luup.call_delay ("NC_RefreshMyExtIP", PollPeriod, lul_device)
I’ve tried to mirror how other plugins have used it both these call back functions, but something doesn’t seem to like me…
When the function runs initially upon start up, the logs show the following…
|
|
|
50 |
01/08/22 15:52:06.881 |
luup_log:1188: ExtIP: Refreshing External IP Address <0x76c92520> |
50 |
01/08/22 15:52:06.881 |
luup_log:1188: ExtIP: lul_device submitted =1188 <0x76c92520> |
50 |
01/08/22 15:52:06.882 |
luup_log:1188: ExtIP: PollPeriod = 60 <0x76c92520> |
50 |
01/08/22 15:52:07.458 |
luup_log:1188: ExtIP: Address check returned = 51.22.33.44 <0x76c92520> |
50 |
01/08/22 15:52:07.458 |
luup_log:1188: ExtIP: Existing IP = 51.22.33.44 <0x76c92520> |
50 |
01/08/22 15:52:07.459 |
luup_log:1188: ExtIP: previousIP = 0.0.0.0 <0x76c92520> |
But when that same function is called via the luup.call_delay, it’s a different picture…
FYI - To avoid getting an error against PollPeriod if it couldn’t retrieve a value, I set it it to use 30, which is why that is presented…
|
|
|
50 |
01/08/22 15:53:07.100 |
luup_log:1188: ExtIP: Refreshing External IP Address <0x74c92520> |
50 |
01/08/22 15:53:07.101 |
luup_log:1188: ExtIP: lul_device submitted =1188 <0x74c92520> |
01 |
01/08/22 15:53:07.102 |
GetLuaInterface can’t find device type: 4/0xf46cf8 str: 1188 <0x74c92520> |
01 |
01/08/22 15:53:07.102 |
luup_variable_get interface 0xf46180 args 3 <0x74c92520> |
50 |
01/08/22 15:53:07.103 |
luup_log:1188: ExtIP: PollPeriod = 30 <0x74c92520> |
50 |
01/08/22 15:53:07.842 |
luup_log:1188: ExtIP: Address check returned = 51.22.33.44 <0x74c92520> |
01 |
01/08/22 15:53:07.843 |
GetLuaInterface can’t find device type: 4/0xf46cf8 str: 1188 <0x74c92520> |
01 |
01/08/22 15:53:07.843 |
luup_variable_get interface 0xf46180 args 3 <0x74c92520> |
01 |
01/08/22 15:53:07.851 |
LuaInterface::CallFunction_Timer-5 function NC_RefreshMyExtIP failed [string module(L_ExternalIP1, package.seeall)…]:29: attempt to concatenate local ‘existingIP’ (a nil value) <0x74c92520> |
So my current thinking is that when the call back is made it’s looking at that function in isolation, so it’s not aware of all the predefined parementers / arguments that it needs to use… Sound plusable . ??
In the interim, you can simply create an interval based scene, using the luup.code I provided earlier>.