[Help] Issue Updating/Syncing Timer in Global Variable and local variable

This is JS in a JS file? It’s missing stuff so it’s hard to tell.

Because you never assign anything to they global variable in your rule. You assign the timer to timerItem instead of timerSunriseBedroom so timerSunriseBedroom remains null forever and when the rule exits timerItem goes away and you lose your reference to the timer.

But it doesn’t really even get that far because you immediately test to see if the timerItem in not null, which it isn’t because you just saved your timer to it, and then you cancel the timer you just created.

It’s not clear to me exactly what you are trying to do with the map. I think you are trying to have a separate timer per triggering item.

I’m that case, your global variable needs to be the map. When you create a new timer, you need to put that rubber into the map using the triggering Item name as the key.

Or you can use the cache as your map. Since these are not shared across rules you should use cache.private. This is already a map stopped outside your rule with the added bonus that you’re times stored there will get cancelled when your rule is unloaded instead of becoming orphaned.

Or you can use TimerMGR from OHRT which does all the management stuff for you.