Shubhamjain007 / openhab

Automatically exported from code.google.com/p/openhab
0 stars 0 forks source link

CommandEvents are ignored #47

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
1. Try to select a radio station
2. The associated rule is not executed

In the current 0.9.0-SNAPSHOT there has been a fix for the drools event queue 
that is maybe the reason of this bug. Just check 
org.openhab.core.rules.internal.RuleService#execute. The following piece of 
code just copies StateEvents, all other events (e.g. CommandEvents) are 
ignored. 

    // now add all recent events to the session
        for(RuleEvent event : clonedQueue) {
            Item item = event.getItem();
            if(ksession!=null && item!=null) {
                if(event instanceof StateEvent) {
                    FactHandle factHandle = factHandleMap.get(item.getName());
                    if(factHandle!=null) {
                        ksession.update(factHandle, item);
                    }
                    ksession.insert(event);
                }
            }
        }

Original issue reported on code.google.com by afuech...@gmail.com on 23 Sep 2011 at 9:34

GoogleCodeExporter commented 8 years ago
changing the if-statement to 

   if(event instanceof StateEvent || event instanceof CommandEvent) {

helps. There seem to be no side effects. Please verify. 

Original comment by afuech...@gmail.com on 23 Sep 2011 at 10:10

GoogleCodeExporter commented 8 years ago
Thanks André, looks as if I indeed introduced this bug with the latest changes 
for fixing the event queue.

Original comment by kai.openhab on 23 Sep 2011 at 7:02

GoogleCodeExporter commented 8 years ago
I have actually removed the if statement completely as it does not seem to make 
any sense at all at that place (probably some copy&paste leftover...)
I didn't test the change, so please let me know, if it is not working as 
expected.

Original comment by kai.openhab on 23 Sep 2011 at 7:32