global_data function using domoticz.openURL
Posted: Wednesday 17 February 2021 16:33
Want to create a function to set the CV temperature. As I need this in a couple of scripts. Via the WebGUI I created a dzevents file called: "global_data". It's being saved to: scripts/dzVents/generated_scripts/global_data.lua.
global_data.lua:
Executing this from another DzEvents script:
It works, until it hits: 'domoticz.openURL(CVURL)'. (line 13)
Thanks!
global_data.lua:
Code: Select all
-- this scripts holds all the globally persistent variables and helper functions
return {
helpers = {
-- Functie op temperatuur te zetten
SETCV = function(GEWENSTETEMP)
local CVHOSTNAME='192.168.0.20'
local SETPOINT=GEWENSTETEMP*10-50
local CVURL='http://'..CVHOSTNAME..'/data.json?heater=0&setpoint='..SETPOINT
print('Verwarming wordt gezet naar: '..GEWENSTETEMP..' graden middels URL: '..CVURL)
domoticz.openURL(CVURL)
end
}
}
Code: Select all
domoticz.helpers.SETCV('20')
Does anybody understand why I'm getting the "nil value" error. Also tried "openURL(CVURL)", and even hardcoding the URL, but it always comes back with that error.2021-02-17 16:28:00.496 Status: dzVents: Info: ------ Start internal script: TEST:, trigger: "every 1 minutes"
2021-02-17 16:28:00.496 Status: dzVents: Verwarming wordt gezet naar: 20 graden middels URL: http://192.168.0.20/data.json?heater=0&setpoint=150.0
2021-02-17 16:28:00.496 Error: dzVents: Error: (3.1.4) An error occurred when calling event handler TEST
2021-02-17 16:28:00.496 Error: dzVents: Error: (3.1.4) ....12934/scripts/dzVents/generated_scripts/global_data.lua:13: attempt to index a nil value (global 'domoticz')
2021-02-17 16:28:00.497 Status: dzVents: Info: ------ Finished TEST
Thanks!