This page last changed on Feb 25, 2015 by gman0105.

Hello,

I have an issue with rules. I have just maid the following test :

package org.openremote.controller.protocol

global org.openremote.controller.statuscache.CommandFacade execute;
global org.openremote.controller.statuscache.SwitchFacade switches;

rule "mail jour"
   Event( source == "DateTime isDay Sensor", value == "true" )
then
   execute.command ( "Send Mail jour" );
end

"DateTime isDay Sensor" sensor created by following your "OpenRemote 2.0 How To - DateTime Protocol"

I found errors in boot.log :

--------------------------------------------------------------------

  DEPLOYING NEW CONTROLLER RUNTIME...

--------------------------------------------------------------------

ERROR 2015-02-25 20:37:04,350 : Rule definition 'modeler_rules.drl' could not be deployed. See errors below.
ERROR 2015-02-25 20:37:04,350 : [ERR 101] Line 7:3 no viable alternative at input 'Event' in rule "mail jour"
ERROR 2015-02-25 20:37:04,351 : There was an error parsing the rule definition 'modeler_rules.drl' : Could not parse knowledge.
java.lang.IllegalArgumentException: Could not parse knowledge.
	at org.drools.builder.impl.KnowledgeBuilderImpl.newKnowledgeBase(KnowledgeBuilderImpl.java:58)
	at org.openremote.controller.statuscache.rules.RuleEngine.getValidKnowledgePackages(RuleEngine.java:532)
	at org.openremote.controller.statuscache.rules.RuleEngine.start(RuleEngine.java:253)
	at org.openremote.controller.statuscache.EventProcessorChain.start(EventProcessorChain.java:112)
	at org.openremote.controller.statuscache.StatusCache.start(StatusCache.java:120)
	at org.openremote.controller.deployer.Version20ModelBuilder.buildSensorModel(Version20ModelBuilder.java:659)
	at org.openremote.controller.deployer.Version20ModelBuilder.build(Version20ModelBuilder.java:557)
	at org.openremote.controller.deployer.AbstractModelBuilder.buildModel(AbstractModelBuilder.java:154)
	at org.openremote.controller.service.Deployer.startup(Deployer.java:872)
	at org.openremote.controller.service.Deployer.softRestart(Deployer.java:454)
	at org.openremote.controller.service.Deployer$ControllerDefinitionWatch.run(Deployer.java:1411)
	at java.lang.Thread.run(Thread.java:662)
INFO 2015-02-25 20:37:04,357 : Initialized event processor : Drools Rule Engine
INFO 2015-02-25 20:37:04,375 : Initialized event processor : RRD4J Data Logger
INFO 2015-02-25 20:37:04,376 : Initialized event processor : EmonCMS Data Logger
INFO 2015-02-25 20:37:04,437 : Registered sensor : Sensor (Name = 'DisplayDate Sensor', ID = '106628481', State Mappings: {})
INFO 2015-02-25 20:37:04,437 : Registered sensor : Sensor (Name = 'DateTime isDay Sensor', ID = '106628482', State Mappings: {})
INFO 2015-02-25 20:37:04,440 : Registered sensor : Switch Sensor (Name = 'ExclusionSwitchSensor', ID = '106629438')
INFO 2015-02-25 20:37:04,442 : Registered sensor : Switch Sensor (Name = 'SMOKE1_ALARM', ID = '106628389')
INFO 2015-02-25 20:37:04,443 : Registered sensor : Level Sensor (Name = 'Position_volet', ID = '106902970', Min: 0, Max: 100)
INFO 2015-02-25 20:37:04,447 : Registered sensor : Switch Sensor (Name = 'inclusionSwitchSensor', ID = '106177579')
INFO 2015-02-25 20:37:04,449 : Registered sensor : Level Sensor (Name = 'SMOKE1_BATTERY_REPORT', ID = '106239579', Min: 0, Max: 100)
INFO 2015-02-25 20:37:04,454 : Startup complete.
INFO 2015-02-25 20:49:15,828 : 

--------------------------------------------------------------------

  DEPLOYING NEW CONTROLLER RUNTIME...

--------------------------------------------------------------------

ERROR 2015-02-25 20:49:18,911 : Rule definition 'modeler_rules.drl' could not be deployed. See errors below.
ERROR 2015-02-25 20:49:18,911 : [ERR 101] Line 7:3 no viable alternative at input 'Event' in rule "mail jour"
ERROR 2015-02-25 20:49:18,914 : There was an error parsing the rule definition 'modeler_rules.drl' : Could not parse knowledge.
java.lang.IllegalArgumentException: Could not parse knowledge.
	at org.drools.builder.impl.KnowledgeBuilderImpl.newKnowledgeBase(KnowledgeBuilderImpl.java:58)
	at org.openremote.controller.statuscache.rules.RuleEngine.getValidKnowledgePackages(RuleEngine.java:532)
	at org.openremote.controller.statuscache.rules.RuleEngine.start(RuleEngine.java:253)
	at org.openremote.controller.statuscache.EventProcessorChain.start(EventProcessorChain.java:112)
	at org.openremote.controller.statuscache.StatusCache.start(StatusCache.java:120)
	at org.openremote.controller.deployer.Version20ModelBuilder.buildSensorModel(Version20ModelBuilder.java:659)
	at org.openremote.controller.deployer.Version20ModelBuilder.build(Version20ModelBuilder.java:557)
	at org.openremote.controller.deployer.AbstractModelBuilder.buildModel(AbstractModelBuilder.java:154)
	at org.openremote.controller.service.Deployer.startup(Deployer.java:872)
	at org.openremote.controller.service.Deployer.startController(Deployer.java:350)
	at org.openremote.controller.spring.SpringContext.initializeController(SpringContext.java:109)
	at org.openremote.controller.service.ServiceContext.init(ServiceContext.java:427)
	at org.openremote.controller.bootstrap.Startup.loadServiceContext(Startup.java:88)
	at org.openremote.controller.bootstrap.servlet.ServletStartup.initializeServiceContext(ServletStartup.java:195)
	at org.openremote.controller.bootstrap.servlet.ServletStartup.contextInitialized(ServletStartup.java:109)
	at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3843)
	at org.apache.catalina.core.StandardContext.start(StandardContext.java:4342)
	at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
	at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
	at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525)
	at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:926)
	at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:889)
	at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:492)
	at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1149)
	at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)
	at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
	at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
	at org.apache.catalina.core.StandardHost.start(StandardHost.java:719)
	at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
	at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
	at org.apache.catalina.core.StandardService.start(StandardService.java:516)
	at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
	at org.apache.catalina.startup.Catalina.start(Catalina.java:578)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
	at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
INFO 2015-02-25 20:49:19,298 : Initialized event processor : Drools Rule Engine
INFO 2015-02-25 20:49:19,475 : Initialized event processor : RRD4J Data Logger
INFO 2015-02-25 20:49:19,475 : Initialized event processor : EmonCMS Data Logger
INFO 2015-02-25 20:49:21,621 : Registered sensor : Sensor (Name = 'DisplayDate Sensor', ID = '106628481', State Mappings: {})
INFO 2015-02-25 20:49:21,624 : Registered sensor : Sensor (Name = 'DateTime isDay Sensor', ID = '106628482', State Mappings: {})
INFO 2015-02-25 20:49:21,626 : Registered sensor : Switch Sensor (Name = 'ExclusionSwitchSensor', ID = '106629438')
INFO 2015-02-25 20:49:21,664 : Registered sensor : Switch Sensor (Name = 'SMOKE1_ALARM', ID = '106628389')
INFO 2015-02-25 20:49:21,666 : Registered sensor : Level Sensor (Name = 'Position_volet', ID = '106902970', Min: 0, Max: 100)
INFO 2015-02-25 20:49:21,668 : Registered sensor : Switch Sensor (Name = 'inclusionSwitchSensor', ID = '106177579')
INFO 2015-02-25 20:49:21,670 : Registered sensor : Level Sensor (Name = 'SMOKE1_BATTERY_REPORT', ID = '106239579', Min: 0, Max: 100)
INFO 2015-02-25 20:49:21,677 : Startup complete.
INFO 2015-02-25 20:49:21,678 : Controller Definition File Watcher for Default Deployer started.

I have maid other test with "event", always with same error ?

Could you help me ?

Thanks

Hi Guillaume

Try adding this line in your .drl file.

import org.openremote.controller.protocol.Event;

Posted by kenta at Feb 26, 2015 06:56

Hi,

I have tried adding

import org.openremote.controller.protocol.Event;

and also using :

package org.openremote.controller.model.event

I have the same error.

Posted by gman0105 at Feb 26, 2015 12:44

package org.openremote.controller.model.event
global org.openremote.controller.statuscache.CommandFacade execute;
global org.openremote.controller.statuscache.SwitchFacade switches;
global org.openremote.controller.statuscache.LevelFacade levels;
import org.openremote.controller.protocol.*;

This blurp works for me. Don't ask me why. No one ever bothered to describe it properly in a help file.

Posted by pz1 at Feb 26, 2015 14:33

this works for me:
try to change to CustomState

rule "lamp vaas aan als nacht"
when
CustomState(source== "isday sensor", value=="false")
then
execute.command("lamp vaas aan");
end

rule "lamp vaas uit als dag"
when
CustomState(source== "isday sensor", value=="true")
then
execute.command("lamp vaas uit");
end

Posted by robnas at Feb 26, 2015 16:19

Thanks everybody,

But that makes me crazy, I have tried PZ1 and ROB advice's. Trying to mixed solution..
always the same error.

Perhaps something to check in Java installation/settings ?

Posted by gman0105 at Feb 26, 2015 18:32

add this in your rules for packages. will always work:

//Package, globals and imports:
package org.openremote.controller.protocol
global org.openremote.controller.statuscache.CommandFacade execute;
global org.openremote.controller.statuscache.SwitchFacade switches;
global org.openremote.controller.statuscache.LevelFacade levels;
import org.openremote.controller.protocol.*;
import org.openremote.controller.model.event.*;
import java.lang.Float;
import java.sql.Timestamp;
import java.util.Date;
import java.util.concurrent.TimeUnit;
import org.openremote.controller.utils.Logger;
import org.openremote.controller.Constants;
import java.io.*;

Posted by robnas at Feb 26, 2015 18:36

I'm sorry, I just forgive to insert "then":

//Package, globals and imports:
package org.openremote.controller.protocol
global org.openremote.controller.statuscache.CommandFacade execute;
global org.openremote.controller.statuscache.SwitchFacade switches;
global org.openremote.controller.statuscache.LevelFacade levels;
import org.openremote.controller.protocol.*;
import org.openremote.controller.model.event.*;
import java.lang.Float;
import java.sql.Timestamp;
import java.util.Date;
import java.util.concurrent.TimeUnit;
import org.openremote.controller.utils.Logger;
import org.openremote.controller.Constants;
import java.io.*;

rule "mail jour"
when
Event(source=="DateTime isDay Sensor", value=="true")
then
execute.command("Send Mail jour");
end

rule "mail nuit"
when
Event(source=="DateTime isDay Sensor", value=="false")
then
execute.command("Send Mail nuit");
end

That works now.

What a shame!

Posted by gman0105 at Feb 26, 2015 20:28

Hi.
On which version, Pro or Free, works DateTime protocol and send e-mail?

Posted by aleksey_z at Feb 27, 2015 09:00

It works for the free version.

Posted by gman0105 at Feb 27, 2015 12:21

Hi.
Which version Java use? 1.6.0_38?
You just stopped the OR, deleted Java8, installed Java6, launched the OR, and the rules work?

Posted by aleksey_z at Feb 27, 2015 13:21
Document generated by Confluence on Jun 05, 2016 09:34