I hope I can illustrate a problem that drove me nuts this afternoon.
I have a universal rule definition that just instantiates a helper object in a library module which gets parametrized by a JSON definition. This helper object also deliveries the trigger definition, which it compiles out of the JSON. It also processes the triggers coming in.
This is a try to convert my current huge DSL rule controlling my 100+ lights (see my Tutorial/Example)
During the tests, I had weird behaviors, which I could not explain, it was haunting.
The reason I realized behind this that when I edited the py files and reloaded all the initiated timers kept running in the background from the zombie instances. The only solution for me was to restart OH.
Is there anything that would guarantee that the instantiated classed and attached times would go away?
from core.log import logging, LOG_PREFIX
from core.rules import rule
import imp
import personal.LightControlLib
imp.reload(personal.LightControlLib)
from personal.LightControlLib import lightManager
log = logging.getLogger(LOG_PREFIX + ".this.is.my.log")
LIGHT_SETTINGS= '''
{
"testGU10L":
{
"ONOF" : 1,
"MIDI" : 7,
"ITLI" : "testGU10L",
"ITIL" : "HallwayDownMotion",
"ITMO" : "HallwayDownMotion"
},
"testGU10M":
{
"ONOF" : 0,
"MIDI" : 7,
"ITLI" : "testGU10M",
"ITIL" : "HallwayDownMotion",
"ITMO" : "HallwayDownMotion"
}
}
'''
LIGHT_TRIGGERS='''
{
"testGU10L":
{
"TOG" : [
["deconz:switch:d6dfbf93:ccccccfffe51c077011000:buttoneven", "2002"],
],
"DIM" : [
["deconz:switch:d6dfbf93:ccccccfffe51c077011000:buttoneven", "2001"],
],
"MOV" : [
["deconz:switch:d6dfbf93:ccccccfffe51c077011000:buttoneven", "2004"],
]
},
"testGU10M":
{
"TOG" : [
["deconz:switch:d6dfbf93:ccccccfffe51c077011000:buttoneven", "1002"]
],
"DIM" : [
["deconz:switch:d6dfbf93:ccccccfffe51c077011000:buttoneven", "1001"]
],
"MOV" : [
["deconz:switch:d6dfbf93:ccccccfffe51c077011000:buttoneven", "1004"]
]
}
}
'''
@rule("Light Manager Rule", description="This is an rule for controlling lights")
class LightManagerRule(object):
lights = lightManager(LIGHT_SETTINGS, LIGHT_TRIGGERS)
def __init__(self):
self.triggers = self.lights.getAllTriggers()
def execute(self, module, inputs):
self.lights.execute(module, inputs)