Thanks for update.
How do you mean global variables? Could you please share some example with me. I think that this should work for me :-).
Also thanks for update regarding feature request - that will be nice in future but I need to find some solution now.
I have shelly 4pm and I would like to use it for lights which will be driven by information if its night (so between sunset-sunrise with some defined offset) and also by shelly inputs through buttons or motion sensors. So in case when input changed its state to ON some event handler on my script will be called. This handler will check if its "night" and then have to decide to set some shelly switch.
Tom