Same function in different scenes luup code - do they interact?

I defined the same function in different scenes. Something like

function afterdelay (mystate) local http = require("socket.http") http.request("http://xx.xx.xx.xx/input4.php?State="..mystate) end luup.call_delay ("afterdelay", 0,0) luup.call_delay ("afterdelay", 4,1)

So “afterdelay” is run two times after the scene gets activated.

Not on purpose I defined “afterdelay” also in an other scene luup code. Today I found out that under certain circumstances I cannot clearly define, one scenes triggers the function of another. I think that happens if both scenes are active. Did I missunderstand the concept? I thought the definition of a function in the luup section of a scene is only valid within that scene and only known to the system during runtime.

Did I understood the concept?

Thanks for any hints.

To my knowledge, each device has its own Lua context, so if you’d done that in a plugin’s implementation file you’d get the behaviour that you expected. Scenes, I think, all run from the _SceneController device (id = 2), so there may be some sharing of context in that case.

Or I could be totally wrong. I’ve read all the same documentation that you have, and you’ve done the experiment and I haven’t…

If the the scenes run under one virtual device, as you described, this behavior could be explained. It is however a very dangerous thing when you don’t know about it. Imagine having a big network with lots of automatic scenes. Its an obvious thing to reuse basic functionalities by copy and paste code of functions. So from now on I have to keep track somehow which function name I already used.

If the mechanism works reliably it could even be used to exchange data between running scenes!