doh wrote: Saturday 13 April 2019 22:40
Is it possible to do something like this in global_data.lua:
Code: Select all
globalvariablename = { initial = domoticz.variables('user_variable_name').value }
I tried this but it doesn't seem to work.
Not possible as the domoticz object is not available in that part of global_data.lua. But what is your usecase if you already have this value in a uservariable ?
What's the best way to initialise globalData values from user variables?
Initialise in a helper function and pass the domoticz object to that helper function.
define helper function in global_data.lua
Code: Select all
helpers = {
mySecretValue = function(dz, var)
return var.value
end,
}
and call with:
Code: Select all
dz.log(dz.helpers.mySecretValue(dz, dz.variables('password')),dz.LOG_FORCE)
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>>
dzVents wiki