Displaying timer on the panel

Michal thanks- below is list of errors i am getting. I have attached the complete rules file as an attachment

ERROR 2017-03-07 00:30:19,860 : [ERR 102] Line 28:4 mismatched input ‘Event’ in rule “turn on gdoor light” in pattern

ERROR [Controller Definition File Watcher for Default Deployer]: [ERR 102] Line 28:4 mismatched input ‘Event’ in rule “turn on gdoor light” in pattern

ERROR 2017-03-07 00:30:19,860 : [ERR 102] Line 47:3 mismatched input ‘Event’ in rule “turn on ws-a light” in pattern

ERROR [Controller Definition File Watcher for Default Deployer]: [ERR 102] Line 47:3 mismatched input ‘Event’ in rule “turn on ws-a light” in pattern

ERROR 2017-03-07 00:30:19,861 : Parser returned a null Package

ERROR [Controller Definition File Watcher for Default Deployer]: Parser returned a null Package

ERROR 2017-03-07 00:30:19,864 : Cannot start event processor ‘Drools Rule Engine’ : Cannot find KieModule: org.default:artifact:1.0.0-SNAPSHOT

java.lang.RuntimeException: Cannot find KieModule: org.default:artifact:1.0.0-SNAPSHOT

at org.drools.compiler.kie.builder.impl.KieServicesImpl.newKieContainer(KieServicesImpl.java:117)

at org.drools.compiler.kie.builder.impl.KieServicesImpl.newKieContainer(KieServicesImpl.java:111)

at org.openremote.controller.statuscache.rules.RuleEngine.start(RuleEngine.java:282)

at org.openremote.controller.statuscache.EventProcessorChain.start(EventProcessorChain.java:136)

at org.openremote.controller.statuscache.StatusCache.start(StatusCache.java:148)

at org.openremote.controller.deployer.Version20ModelBuilder.buildSensorModel(Version20ModelBuilder.java:701)

at org.openremote.controller.deployer.Version20ModelBuilder.build(Version20ModelBuilder.java:595)

at org.openremote.controller.deployer.AbstractModelBuilder.buildModel(AbstractModelBuilder.java:154)

at org.openremote.controller.service.Deployer.startup(Deployer.java:1060)

at org.openremote.controller.service.Deployer.softRestart(Deployer.java:455)

at org.openremote.controller.service.Deployer$ControllerDefinitionWatch.run(Deployer.java:1642)

at java.lang.Thread.run(Thread.java:745)

ERROR [Controller Definition File Watcher for Default Deployer]: Cannot start event processor ‘Drools Rule Engine’ : Cannot find KieModule: org.default:artifact:1.0.0-SNAPSHOT

java.lang.RuntimeException: Cannot find KieModule: org.default:artifact:1.0.0-SNAPSHOT

at org.drools.compiler.kie.builder.impl.KieServicesImpl.newKieContainer(KieServicesImpl.java:117)

at org.drools.compiler.kie.builder.impl.KieServicesImpl.newKieContainer(KieServicesImpl.java:111)

at org.openremote.controller.statuscache.rules.RuleEngine.start(RuleEngine.java:282)

at org.openremote.controller.statuscache.EventProcessorChain.start(EventProcessorChain.java:136)

at org.openremote.controller.statuscache.StatusCache.start(StatusCache.java:148)

at org.openremote.controller.deployer.Version20ModelBuilder.buildSensorModel(Version20ModelBuilder.java:701)

at org.openremote.controller.deployer.Version20ModelBuilder.build(Version20ModelBuilder.java:595)

at org.openremote.controller.deployer.AbstractModelBuilder.buildModel(AbstractModelBuilder.java:154)

at org.openremote.controller.service.Deployer.startup(Deployer.java:1060)

at org.openremote.controller.service.Deployer.softRestart(Deployer.java:455)

at org.openremote.controller.service.Deployer$ControllerDefinitionWatch.run(Deployer.java:1642)

at java.lang.Thread.run(Thread.java:745)

Warning: Could not get charToByteConverterClass!

modeler_rules.drl (2.3 KB)

Yes, I have no idea why they did it. Anyway, the fix is very simple. Replace every OR on RHS with ||, i.e.
rule “turn on gdoor light”

when

Event( source == “Garage door sensor”, value == “on” )

Event( source == “MONOPRICE_DOORSENSE_A”, value == “open” )

then

execute.command( “MONOPRICE_DIMMER_ON” );

end

``

Hi Michal

using || instead of “OR” in those rules cleared up all the errors. I am now running OR2.6 and Drools seem to be working with Java 8

Getting a timer to display on UI was the original reason why I started looking in to these options which seem to be “almost working” as well with OR2.6

The rules below kick off the timer and it diplay on the UI and decrements but at the rate of almost 1 tick every 0.5 seconds- so basically 30s timer gets to zero in 15 secs. Not sure why. As always any clues would be greatly appreciated. These are set of rules I am using for displaying the timer and decrementing it on the UI.

// virtual switch for garage light

rule “turn on garage light after 30 seconds”

timer (int: 30s)

when

Event( source == “VS_Gdoor_status”, value == “ON” )

then

execute.command( “MONOPRICE_DIMMER_DIM_40” );

execute.command( “VC_Gdoor_OFF” );

//execute.command( “VS_Gdoor_timer”, 0);

end

// 30 second timer display for virtual switch for garage door to insert delay in closing

rule “30 sec counter initialize”

when

Event( source == “VS_Gdoor_status”, value == “ON” )

then

execute.command( “VS_Gdoor_timer”, 30);

end

rule “30 sec counter decrement”

timer (int: 0s 1s)

when

Event( source == “VS_Gdoor_timer_sensor”, $v : value > 0 )

then

Integer i = Integer.parseInt($v.toString());

i = i - 1;

execute.command (“VS_Gdoor_timer”, i );

end

I tried changing the timer (int: 0s 1s) to (int: 0s 2s) and still it seems to be decrementing at the same rate of 1 tick per 0.5 secs

Try timer(int: 1s)

Thanks again… timer(int: 1s) seems to work- although there is some lag by around 7 seconds or so for the 30 sec timer but close enough :slight_smile:

it does leave me a little confused on the timer syntax and operation though.

really appreciate all the help.

I'm glad to hear you've got it working.

If I may throw a penny worth of thoughts in. (I'm happy to be corrected)

I think you were confusing the timer by calling two lots​ of seconds.

You said before that the timer can accept two (or more) values.

However, I'd suggest that two different values would be required.

(Int: 1m 15s)

(Int: 3h 6m 10s)

Stuart thanks for your help getting me started on this.

with regards to the timer function i have another rule as below for polling a wall switch every 3 mins which is working fine- so i don’t belive it is the syntax that is an issue but rather the usage- i think this rule for the timer is checking status of a sensor every time before it executes, than waits 1 sec before it executes vs the for rule below the left hand side is always true and so it keeps executing with a delay of 180s between each execution. I am not sure if i am expressing myself correctly :slight_smile: this link here explains the parameters in a timer better. but again i could be wrong- i am still a novice when it comes to OpenRemote

https://github.com/openremote/Documentation/wiki/Rules

rule “poll wall switch-a”

timer (int: 0s 180s)

when

eval (true)

then

execute.command(“Linear_WS15Z-1_A_STATUS”);

end