Zwave and Rules error java.lang.numberformatexception

51 views
Skip to first unread message

orct...@gmail.com

unread,
Jul 2, 2018, 11:07:54 PM7/2/18
to OpenRemote
Hi

i am using RRD4 for graphing some values from a multi sensor. Everything was working fine for quite sometime until a few week ago when i noticed the graphing was not working any more.
Unfortunately, I am not able to trace back and see what changes i made that possibly broke this graph. I have not made any changes directly related to this rules file or the rrd4j config.



in order to display the values on the graph, i had to create rules for converting the raw (or i believe they are string values) passed by the zwave multisensor and convert them to integer and i used those as source for the RRD4J graph in the rrd4j config file (attached). The rule files is as follows for converting those raw values from the zwave sensor to integers:

import java.util.*;
import java.lang.Integer;


rule "luminance"
when
 Event( source == "MS2lumsensor", $l : value > 0 )
then
 int i = Integer.parseInt($l.toString());
 i=i+1;
 execute.command ("vsms2lumcom", i );
end

rule "humidity"
when
 Event( source == "MS2humsensor", $h : value > 0 )
then
 int i = Integer.parseInt($h.toString());
 i=i+1;
 execute.command ("vsmshum2com", i );
end

rule "temperature"
when
 Event( source == "MS2tempFsensor", $t : value > 0 )
then
 int i = Integer.parseInt($t.toString());
 i=i+1;
 execute.command ("vsmstemp2com", i );
end

The rule file gets added without errors but on the termin i see the following when the rules seem to triggered:

ERROR 2018-07-02 22:49:07,389 : Error in executing rule : MS2lumsensor:Exception executing consequence for rule "luminance" in org.openremote.controller.protocol: java.lang.NumberFormatException: For input string: "83.44"
    Event org.openremote.controller.model.event.CustomState@a6eff23c not processed!
Exception executing consequence for rule "luminance" in org.openremote.controller.protocol: java.lang.NumberFormatException: For input string: "83.44"
    at org.drools.core.runtime.rule.impl.DefaultConsequenceExceptionHandler.handleException(DefaultConsequenceExceptionHandler.java:39)
    at org.drools.core.common.DefaultAgenda.fireActivation(DefaultAgenda.java:1100)
    at org.drools.core.phreak.RuleExecutor.fire(RuleExecutor.java:121)
    at org.drools.core.phreak.RuleExecutor.evaluateNetworkAndFire(RuleExecutor.java:74)
    at org.drools.core.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:1007)
    at org.drools.core.common.DefaultAgenda.fireLoop(DefaultAgenda.java:1350)
    at org.drools.core.common.DefaultAgenda.fireAllRules(DefaultAgenda.java:1288)
    at org.drools.core.impl.StatefulKnowledgeSessionImpl.internalFireAllRules(StatefulKnowledgeSessionImpl.java:1306)
    at org.drools.core.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:1297)
    at org.drools.core.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:1278)
    at org.openremote.controller.statuscache.rules.RuleEngine.push(RuleEngine.java:203)
    at org.openremote.controller.statuscache.EventProcessorChain.push(EventProcessorChain.java:196)
    at org.openremote.controller.statuscache.StatusCache.update(StatusCache.java:293)
    at org.openremote.controller.model.sensor.Sensor.update(Sensor.java:367)
    at org.openremote.protocol.zwave.ZWaveCommand.updateSensors(ZWaveCommand.java:587)
    at org.openremote.protocol.zwave.model.commandclasses.CCMultiLevelSensor.updateSensorCommand(CCMultiLevelSensor.java:1769)
    at org.openremote.protocol.zwave.model.commandclasses.CCMultiLevelSensor.linkSensorCommand(CCMultiLevelSensor.java:1357)
    at org.openremote.protocol.zwave.model.ZWaveNode.linkSensorCommand(ZWaveNode.java:858)
    at org.openremote.protocol.zwave.model.ZWaveNode.addSensorCommand(ZWaveNode.java:993)
    at org.openremote.protocol.zwave.ZWaveCommand.setSensor(ZWaveCommand.java:461)
    at org.openremote.controller.model.sensor.Sensor.start(Sensor.java:412)
    at org.openremote.controller.deployer.Version20ModelBuilder.buildSensorModel(Version20ModelBuilder.java:718)
    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)
Caused by: java.lang.NumberFormatException: For input string: "83.44"
    at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
    at java.lang.Integer.parseInt(Integer.java:580)
    at java.lang.Integer.parseInt(Integer.java:615)
    at org.openremote.controller.protocol.Rule_luminance427027631.defaultConsequence(Rule_luminance427027631.java:7)
    at org.openremote.controller.protocol.Rule_luminance427027631DefaultConsequenceInvokerGenerated.evaluate(Unknown Source)
    at org.openremote.controller.protocol.Rule_luminance427027631DefaultConsequenceInvoker.evaluate(Unknown Source)
    at org.drools.core.common.DefaultAgenda.fireActivation(DefaultAgenda.java:1089)

... 26 more
ERROR [Controller Definition File Watcher for Default Deployer]: Error in executing rule : MS2lumsensor:Exception executing consequence for rule "luminance" in org.openremote.controller.protocol: java.lang.NumberFormatException: For input string: "83.44"
    Event org.openremote.controller.model.event.CustomState@a6eff23c not processed!
Exception executing consequence for rule "luminance" in org.openremote.controller.protocol: java.lang.NumberFormatException: For input string: "83.44"
    at org.drools.core.runtime.rule.impl.DefaultConsequenceExceptionHandler.handleException(DefaultConsequenceExceptionHandler.java:39)
    at org.drools.core.common.DefaultAgenda.fireActivation(DefaultAgenda.java:1100)
    at org.drools.core.phreak.RuleExecutor.fire(RuleExecutor.java:121)
    at org.drools.core.phreak.RuleExecutor.evaluateNetworkAndFire(RuleExecutor.java:74)
    at org.drools.core.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:1007)
    at org.drools.core.common.DefaultAgenda.fireLoop(DefaultAgenda.java:1350)
    at org.drools.core.common.DefaultAgenda.fireAllRules(DefaultAgenda.java:1288)
    at org.drools.core.impl.StatefulKnowledgeSessionImpl.internalFireAllRules(StatefulKnowledgeSessionImpl.java:1306)
    at org.drools.core.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:1297)
    at org.drools.core.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:1278)
    at org.openremote.controller.statuscache.rules.RuleEngine.push(RuleEngine.java:203)
    at org.openremote.controller.statuscache.EventProcessorChain.push(EventProcessorChain.java:196)
    at org.openremote.controller.statuscache.StatusCache.update(StatusCache.java:293)
    at org.openremote.controller.model.sensor.Sensor.update(Sensor.java:367)
    at org.openremote.protocol.zwave.ZWaveCommand.updateSensors(ZWaveCommand.java:587)
    at org.openremote.protocol.zwave.model.commandclasses.CCMultiLevelSensor.updateSensorCommand(CCMultiLevelSensor.java:1769)
    at org.openremote.protocol.zwave.model.commandclasses.CCMultiLevelSensor.linkSensorCommand(CCMultiLevelSensor.java:1357)
    at org.openremote.protocol.zwave.model.ZWaveNode.linkSensorCommand(ZWaveNode.java:858)
    at org.openremote.protocol.zwave.model.ZWaveNode.addSensorCommand(ZWaveNode.java:993)
    at org.openremote.protocol.zwave.ZWaveCommand.setSensor(ZWaveCommand.java:461)
    at org.openremote.controller.model.sensor.Sensor.start(Sensor.java:412)
    at org.openremote.controller.deployer.Version20ModelBuilder.buildSensorModel(Version20ModelBuilder.java:718)
    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)
Caused by: java.lang.NumberFormatException: For input string: "83.44"
    at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
    at java.lang.Integer.parseInt(Integer.java:580)
    at java.lang.Integer.parseInt(Integer.java:615)
    at org.openremote.controller.protocol.Rule_luminance427027631.defaultConsequence(Rule_luminance427027631.java:7)
    at org.openremote.controller.protocol.Rule_luminance427027631DefaultConsequenceInvokerGenerated.evaluate(Unknown Source)
    at org.openremote.controller.protocol.Rule_luminance427027631DefaultConsequenceInvoker.evaluate(Unknown Source)
    at org.drools.core.common.DefaultAgenda.fireActivation(DefaultAgenda.java:1089)
    ... 26 more
ERROR 2018-07-02 22:49:07,394 : Root Cause:

java.lang.NumberFormatException: For input string: "83.44"
    at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
    at java.lang.Integer.parseInt(Integer.java:580)
    at java.lang.Integer.parseInt(Integer.java:615)
    at org.openremote.controller.protocol.Rule_luminance427027631.defaultConsequence(Rule_luminance427027631.java:7)
    at org.openremote.controller.protocol.Rule_luminance427027631DefaultConsequenceInvokerGenerated.evaluate(Unknown Source)
    at org.openremote.controller.protocol.Rule_luminance427027631DefaultConsequenceInvoker.evaluate(Unknown Source)
    at org.drools.core.common.DefaultAgenda.fireActivation(DefaultAgenda.java:1089)
    at org.drools.core.phreak.RuleExecutor.fire(RuleExecutor.java:121)
    at org.drools.core.phreak.RuleExecutor.evaluateNetworkAndFire(RuleExecutor.java:74)
    at org.drools.core.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:1007)
    at org.drools.core.common.DefaultAgenda.fireLoop(DefaultAgenda.java:1350)
    at org.drools.core.common.DefaultAgenda.fireAllRules(DefaultAgenda.java:1288)
    at org.drools.core.impl.StatefulKnowledgeSessionImpl.internalFireAllRules(StatefulKnowledgeSessionImpl.java:1306)
    at org.drools.core.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:1297)
    at org.drools.core.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:1278)
    at org.openremote.controller.statuscache.rules.RuleEngine.push(RuleEngine.java:203)
    at org.openremote.controller.statuscache.EventProcessorChain.push(EventProcessorChain.java:196)
    at org.openremote.controller.statuscache.StatusCache.update(StatusCache.java:293)
    at org.openremote.controller.model.sensor.Sensor.update(Sensor.java:367)
    at org.openremote.protocol.zwave.ZWaveCommand.updateSensors(ZWaveCommand.java:587)
    at org.openremote.protocol.zwave.model.commandclasses.CCMultiLevelSensor.updateSensorCommand(CCMultiLevelSensor.java:1769)
    at org.openremote.protocol.zwave.model.commandclasses.CCMultiLevelSensor.linkSensorCommand(CCMultiLevelSensor.java:1357)
    at org.openremote.protocol.zwave.model.ZWaveNode.linkSensorCommand(ZWaveNode.java:858)
    at org.openremote.protocol.zwave.model.ZWaveNode.addSensorCommand(ZWaveNode.java:993)
    at org.openremote.protocol.zwave.ZWaveCommand.setSensor(ZWaveCommand.java:461)
    at org.openremote.controller.model.sensor.Sensor.start(Sensor.java:412)
    at org.openremote.controller.deployer.Version20ModelBuilder.buildSensorModel(Version20ModelBuilder.java:718)
    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]: Root Cause:

rrd4j-config.xml

Michal Rutka

unread,
Jul 3, 2018, 4:24:34 AM7/3/18
to orct...@gmail.com, OpenRemote
From errors it is clear that you have number format exception and the command which drives your graphs is not executed. The reason for the error is that you are trying to parse an integer while the input string contains float number. Therefore, instead Integer.parseInt() use Double.parseDouble() function. Better yet encapsulate it with try{}except{} block like this:

  double d;
  try{
    d = Double.parseDouble($l.toString());
  } catch (NumberFormatException e) {
    d = 0.0;
  }

Kind regards,
Michal

--
You received this message because you are subscribed to the Google Groups "OpenRemote" group.
To unsubscribe from this group and stop receiving emails from it, send an email to openremotecommunity+unsub...@googlegroups.com.
Visit this group at https://groups.google.com/group/openremotecommunity.
To view this discussion on the web visit https://groups.google.com/d/msgid/openremotecommunity/19271448-02fe-4f92-a7a5-c65a027bce14%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Michal Rutka
www.mqlservice.net

orct...@gmail.com

unread,
Mar 16, 2019, 1:17:42 AM3/16/19
to OpenRemote

Hi Michael,

i tried using it in the rules as you have suggested above but now the rules files is not getting included with following errors as below. I wond if it is related to the changes made in the zwave 3.3.0 as per the thread below. I think my original rule stopped working after i updated the Zwave file to 3.3.0


Rule:

package org.openremote.controller.protocol

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


import java.util.*;
import java.lang.Integer;

rule "luminance"
when
 Event( source == "MS2lumsensor", $l : value > 0 )
then
 //double i = Double.parseDouble($l.toString());
 //i=i+1;
 double d;
 try{
    d = Double.parseDouble($l.toString());
  } catch (NumberFormatException e) {
    d = 0.0;
  }

  execute.command ("vsms2lumcom", d );

end


rule "humidity"
when
 Event( source == "MS2humsensor", $h : value > 0 )
then
 //double i = Double.parseDouble($h.toString());
 //i=i+1;
 try{
    d = Double.parseDouble($h.toString());

  } catch (NumberFormatException e) {
    d = 0.0;
  }

  execute.command ("vsmshum2com", d );

end


rule "temperature"
when
 Event( source == "MS2tempFsensor", $t : value > 0 )
then
 //double i = Double.parseDouble($t.toString());
 //i=i+1;
 try{
    d = Double.parseDouble($t.toString());

  } catch (NumberFormatException e) {
    d = 0.0;
  }
execute.command ("vsmstemp2com", d );
end

ERRORS:
ERROR [main]: Unable to build KieBaseModel:OpenRemoteKBase
Rule Compilation error : [Rule name='luminance']
    org/openremote/controller/protocol/Rule_luminance882919569.java (16:745) : The method command(String, String) in the type CommandFacade is not applicable for the arguments (String, double)

Rule Compilation error : [Rule name='humidity']
    org/openremote/controller/protocol/Rule_humidity127941601.java (10:627) : d cannot be resolved to a variable
    org/openremote/controller/protocol/Rule_humidity127941601.java (12:708) : d cannot be resolved to a variable
    org/openremote/controller/protocol/Rule_humidity127941601.java (15:756) : d cannot be resolved to a variable

Rule Compilation error : [Rule name='temperature']
    org/openremote/controller/protocol/Rule_temperature1602332535.java (10:631) : d cannot be resolved to a variable
    org/openremote/controller/protocol/Rule_temperature1602332535.java (12:712) : d cannot be resolved to a variable
    org/openremote/controller/protocol/Rule_temperature1602332535.java (14:759) : d cannot be resolved to a variable


ERROR 2019-03-16 01:03:19,123 : Rule definition 'graph multisensor.drl' could not be deployed. See errors below.
ERROR [main]: Rule definition 'graph multisensor.drl' could not be deployed. See errors below.
ERROR 2019-03-16 01:03:19,124 : Rule Compilation error The method command(String, String) in the type CommandFacade is not applicable for the arguments (String, double)
ERROR [main]: Rule Compilation error The method command(String, String) in the type CommandFacade is not applicable for the arguments (String, double)
ERROR 2019-03-16 01:03:19,125 : Rule Compilation error d cannot be resolved to a variable
d cannot be resolved to a variable
d cannot be resolved to a variable
ERROR [main]: Rule Compilation error d cannot be resolved to a variable
d cannot be resolved to a variable
d cannot be resolved to a variable
ERROR 2019-03-16 01:03:19,126 : Rule Compilation error d cannot be resolved to a variable
d cannot be resolved to a variable
d cannot be resolved to a variable
ERROR [main]: Rule Compilation error d cannot be resolved to a variable
d cannot be resolved to a variable
d cannot be resolved to a variable


orct...@gmail.com

unread,
Mar 16, 2019, 1:24:00 AM3/16/19
to OpenRemote
i tried adding import java.lang.Double; to see if it helps but no luck.

orct...@gmail.com

unread,
Mar 16, 2019, 1:49:47 AM3/16/19
to OpenRemote
I followed some instructions at this link below and add string.format (".%3f, which seems to successfully add the rules fule without errors but i am wondering if it will work for the graphing which i think requires a number instead of a string for plotting

Michal Rutka

unread,
Mar 16, 2019, 6:38:35 AM3/16/19
to orct...@gmail.com, OpenRemote
Hi,

The errors given by compiler explain it all.

In the rule “luminance” and all others you need to convert the second argument to a String as command() expects two strings as arguments, just like in my old blog post http://simpleremote.nl/2013/05/22/temperature-sensors-calibration/

In rules “humidity” and “temperature” you’ve forgot to declare d, look at your “luminance” rule where it is declared.

Kind regards,
Michal

--
You received this message because you are subscribed to the Google Groups "OpenRemote" group.
To unsubscribe from this group and stop receiving emails from it, send an email to openremotecommu...@googlegroups.com.

Michal Rutka

unread,
Mar 16, 2019, 6:45:23 AM3/16/19
to orct...@gmail.com, OpenRemote
What graphing are you referring to? If you are using emoncms.org they it uses API where sending numbers as strings is OK.

On 16 Mar 2019, at 06:49, orct...@gmail.com wrote:

I followed some instructions at this link below and add string.format (".%3f, which seems to successfully add the rules fule without errors but i am wondering if it will work for the graphing which i think requires a number instead of a string for plotting


--
You received this message because you are subscribed to the Google Groups "OpenRemote" group.
To unsubscribe from this group and stop receiving emails from it, send an email to openremotecommu...@googlegroups.com.

orct...@gmail.com

unread,
Mar 16, 2019, 10:25:02 AM3/16/19
to OpenRemote

I have thought of switching over to Emoncms but currently i am using RRD4J.

however for now after i let this running overnight with the changes to rules as per the previous post, i am not seeing any values in graph since July of last year which is when it stopped working (i think this would be when i changed to zwave 3.3.0. because prior to that the raw values were not showing any decimal and were integers.

Further the virtual sensors are displaying 0 on the UI panel so looks like the rule is not transferring values over from actual sensors to the virtual sensors.

i have attached document with screenshot.

when i look at the drools log file, it appears that the rule is getting triggered

DEBUG 2019-03-16 10:11:50,562 (Drools): rule "temperature" // (package org.openremote.controller.protocol)
    Declarations
        Declaration: "$t: 56.3"
    LHS objects(antecedents)
        Class: "CustomState"
        Fields:
            Event Name:     "MS2tempFsensor"
            Event Value:     "56.3"

DEBUG 2019-03-16 10:11:50,651 (Drools): rule "humidity" // (package org.openremote.controller.protocol)
    Declarations
        Declaration: "$h: 37.5"
    LHS objects(antecedents)
        Class: "CustomState"
        Fields:
            Event Name:     "MS2humsensor"
            Event Value:     "37.5"

DEBUG 2019-03-16 10:11:50,738 (Drools): rule "luminance" // (package org.openremote.controller.protocol)
    Declarations
        Declaration: "$l: 48.43"
    LHS objects(antecedents)
        Class: "CustomState"
        Fields:
            Event Name:     "MS2lumsensor"
            Event Value:     "48.43"

virtual sensor values.docx

Michal Rutka

unread,
Mar 16, 2019, 10:59:40 AM3/16/19
to orct...@gmail.com, OpenRemote
IMHO you have problems with conversion to doubles. Because this code is in try{}catch(){} block you don’t see exceptions in the log. Try to do parseDouble outside the try{} and see if there are any errors.

--
You received this message because you are subscribed to the Google Groups "OpenRemote" group.
To unsubscribe from this group and stop receiving emails from it, send an email to openremotecommu...@googlegroups.com.
Visit this group at https://groups.google.com/group/openremotecommunity.

For more options, visit https://groups.google.com/d/optout.
<virtual sensor values.docx>

Message has been deleted

Michal Rutka

unread,
Mar 17, 2019, 4:15:07 AM3/17/19
to orct...@gmail.com, OpenRemote
I’m not expert in rrd4j, but obviously it’s the problem in this case as you see the changing sensor value. Try to simplify the graph, remove AVERAGE functions, btw why you have 5 definitions?

Kind regards,
Michal Rutka

On 17 Mar 2019, at 05:24, orct...@gmail.com wrote:

Thanks Michal.

i agree it is something to with the parseDouble but i cant really figure it out yet. To eliminate any of the conversions being an issue, i decided to test out the the graphing with RRD4J with a simple in virtual sensor (of type custom) with rule that increments it every minute till it reaches 99 and then resets it to 1.

Unfortunately, i cant get this to show up on the graph as well.  I am at a loss as why no data is being logged in the .rrd file (it gets created the when the controller starts but i dont see it being updated there after based on the time stamp)

the counter itself is working fine and gets incremented every min as expected as i can see it on the panel. I have copy/pasted the rule and rrd4j config file below. If you see anything obvious that i may be missing, please let me know.

are there any specific log files that show when the data gets put in to the .rrd file?

Thanks for helping out with this

rrd4j config file:
________________________________________________

<?xml version="1.0" encoding="UTF-8"?>
<rrd4j xmlns="http://www.openremote.org" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.openremote.org http://www.openremote.org/schemas/rrd4j.xsd">

  <rrdDB fileName="graph.rrd" step="60">
        <datasource name="countersensor" type="GAUGE" heartbeat="120" />
   
        <archive function="AVERAGE" xff="0.5" steps="1" rows="300" />
    <archive function="AVERAGE" xff="0.5" steps="10" rows="144" />
    <archive function="AVERAGE" xff="0.5" steps="15" rows="672" />
    <archive function="AVERAGE" xff="0.5" steps="60" rows="744" />
    <archive function="AVERAGE" xff="0.5" steps="120" rows="4380" />
  </rrdDB>
 
  <rrd_graph_def name="graph2">
     <options>
         <vertical_label>count</vertical_label>
         <title>counter</title>
     </options>
     <datasources>
         <def>
             <name>countersensor1</name>
             <rrd>graph.rrd</rrd>
             <source>countersensor</source>
             <cf>AVERAGE</cf>
         </def>
     
     </datasources>
     <graph>
         <line>
             <datasource>countersensor1</datasource>
             <color>#FF0000</color>
             <legend>%Lum\r</legend>
             <width>2</width>
         </line>
     
        <comment>This chart displays counter values.</comment>
     </graph>
 </rrd_graph_def>
 
 
</rrd4j>
_________________________________________________________
Rule file:  (counter sensor is tied to counter command).....

package org.openremote.controller.protocol

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

import java.util.*;
import java.lang.Integer;
//import java.util.regex.*;
//import java.lang.*;
//import java.lang.reflect.Method;

rule "assign"
when
eval(true);
then
 execute.command( "countercommand", 1);
end

rule "counterdecrement"
timer (int: 1m)
when
 Event( source == "countersensor", $v:value > 0 )
then
 int i = Integer.parseInt($v.toString());
 i = i + 1;
 execute.command ("countercommand", i );
end

rule "counter reset"
when
 Event( source == "countersensor", $a:value > 99 )
then
 int j = Integer.parseInt($a.toString());
 j = 1;
 execute.command ("countercommand", j );
end



--
You received this message because you are subscribed to the Google Groups "OpenRemote" group.
To unsubscribe from this group and stop receiving emails from it, send an email to openremotecommu...@googlegroups.com.
Visit this group at https://groups.google.com/group/openremotecommunity.

orct...@gmail.com

unread,
Mar 17, 2019, 11:55:14 PM3/17/19
to OpenRemote
Thanks Michal. Although I can't still figure out why the parse double is not working, I was able to get the graph working. I noticed it takes 10 mins or so before the values start showing up after restarting the controller.

Also because of averaging, I had to really zoom in to within a day to see the graph.

All my sensors were custom sensors. I changed them to level sensors after which they did not show decimal values and I used parse integer which seems to work. I will do a little more testing and post my working rrd4j config file and the rules file for future reference by others.

I am still interested in trying emoncms. The instructions for it don't seem complete or they may be for a previous version. I will start a new discussion to ask for some additional help on it.

Robnas

unread,
Nov 11, 2019, 4:04:22 AM11/11/19
to OpenRemote
Michal,

i have another issue, you wrote a scipt in the past to remeber the values of the sensors > https://www.simpleremote.nl/tag/rules/
it worked perfectly untill i installed the new controller, probably drools has also a new version. ive got this error:
error:
ERROR 2019-11-07 13:37:10,497 : Rule definition 'a_startup_rules.drl' could not be deployed. See errors below.
ERROR 2019-11-07 13:37:10,498 : [ERR 102] Line 48:2 mismatched input 'Event' in rule "Init values" in pattern
ERROR 2019-11-07 13:37:10,498 : [ERR 102] Line 49:2 mismatched input 'Event' in rule "Init values"

which refers to these lines:
  Event($s:source matches "^GV.*", value=="")
  Event($s:source matches "^GV.*", value=="status")



do you know how to solve this one?
thnx


Reply all
Reply to author
Forward
0 new messages