Hello I have an issue that when luup code is executed as a result of some condition being met, it fails when it comes to use a global variable.
I have set a recurring trigger to execute every 5 minutes.
code as follows:
local x = 999
luup.log(“5 mins test”)
global_heat_on = “HeatOff”
– define new global variable
Global_test = 888
luup.log("global txt var "…global_heat_on)
luup.log("local numeric var "…x)
luup.log("defined here global numeric var "…Global_test)
luup.log("defined else where global numeric var "…Power_shunt_triggers)
luup.log(“5 mins complete”)
the above code fails on this line
luup.log("defined here global numeric var "…Global_test)
If I take that line out, the following line fails.
Seems to me the plugin can’t handle global numerics.
Is this a bug or is this a known feature?
Global variable are GLOBAL only to the particular PLEG or PLTS device instance. i.e. they can be shared between actions in the same PLEG/PLTS device.
Each Plugin in VERA has it’s own LUA name space (Context). This is different then the LUA namespace used for LUA Startup and Scene LUA. The latter uses it’s own namespace.
Note: The above information is in the documentation.
Ok I continue my education it would seem. Can you advise how I might pass information between different names spaces? Is there not something that is actually global?
How is it that text data seems to work while numeric data doesn’t?
You say this restriction is documented, can you provide the url? I don’t mind reading docs.
I’ve been reading a manual for the last hour or so and I’m struggling.
Device Variables are global!
i.e. use luup.variable_get and luup.variable_set, the Variable Plugin provides a place to visualize these variables.
But you can create and access variables attached to any device … You can use luup.variable_set to create a variable.
There is NO way to delete a variable that has been created!