Try my.light = on; before the lightrange declaration,just wondering if it needs to be activated to get a consistent light effect without the switching happening on you.
Mind you, dont know your syntax arangment my->, I'm more used to my_lightred and so on like this;