Give value in rules for command

  1. In the rules you are watching for “ON” string while in commands you generate “on” string. You can either change command definition or rules to have the same case strings.
  2. You’ve put everything in one address “settempa”, however very command should have different address, for example “settempa”, “settempainc” and “settempadec”.

Make above changes and it should work, in case of troubles look in boot.log and rules/drools.log

Boot log still is having messages about “Unable to retrieve controller identity”, but I don’t think it matters. Drools log says:

DEBUG 2017-03-15 19:35:25,975 (Drools): File read error: TargetTemp1

DEBUG 2017-03-15 19:35:26,134 (Drools): Inserted new event source “TargetTemp2”

DEBUG 2017-03-15 19:35:26,135 (Drools): Fact count changed from 9 to 1 on “TargetTemp2”

DEBUG 2017-03-15 19:35:26,140 (Drools): Inserted new event source “TargetTemp3”

DEBUG 2017-03-15 19:35:26,141 (Drools): Fact count changed from 1 to 2 on “TargetTemp3”

DEBUG 2017-03-15 19:35:26,146 (Drools): Inserted new event source “Pin3Status”

DEBUG 2017-03-15 19:35:26,147 (Drools): Fact count changed from 2 to 3 on “Pin3Status”

DEBUG 2017-03-15 19:35:26,149 (Drools): Inserted new event source “TargetTemp1”

DEBUG 2017-03-15 19:35:26,149 (Drools): Fact count changed from 3 to 4 on “TargetTemp1”

DEBUG 2017-03-15 19:35:26,184 (Drools): Inserted new event source “Pin0Status”

DEBUG 2017-03-15 19:35:26,184 (Drools): Fact count changed from 4 to 5 on “Pin0Status”

DEBUG 2017-03-15 19:35:26,185 (Drools): Inserted new event source “Pin2Status”

DEBUG 2017-03-15 19:35:26,186 (Drools): Fact count changed from 5 to 6 on “Pin2Status”

DEBUG 2017-03-15 19:35:26,935 (Drools): Inserted new event source “Temp2”

DEBUG 2017-03-15 19:35:26,936 (Drools): Fact count changed from 6 to 7 on “Temp2”

DEBUG 2017-03-15 19:35:26,975 (Drools): Inserted new event source “Temp1”

DEBUG 2017-03-15 19:35:26,976 (Drools): Fact count changed from 7 to 8 on “Temp1”

DEBUG 2017-03-15 19:35:27,018 (Drools): Inserted new event source “Temp3”

DEBUG 2017-03-15 19:35:27,018 (Drools): Fact count changed from 8 to 9 on “Temp3”

``

So I guess it is something wrong with TargetTemp1 “status” command and putting virtual value into it?

In drools.log I don't see any rule executed, not even the initialization one. Therefore I conclude that there must be some errors in the drl file, which you should spot in the boot.log.

These are boot.log and drools.log files, I cannot spot anything in them, except that “Unable to retrieve controller identity” stuff. May it cause problems?

boot.log (5.56 KB)

drools.log (1.79 KB)

This time the initialize rule executes. So everything seems OK. What is the problem then? You haven't press increase/decrease buttons because they are not logged.

Hi Michal,
Thank you so much for helping me. So, finally I’ve got TargetTemp value to show, but I still cannot change it. And the log file does not show any buttons pressed. I’ve tried other rules I found on the forum archive but they do not work either. I’m not sure, but I thing the problem is in this code and somehow it depends on the string format. Am I correct? And if yes, how to alter the code properly?

rule “Initialise”
salience 10
then
execute.command(“TargetTemp1”,_ReadFromFile(“TargetTemp1”,“20.0”));
end

function void _WriteToFile(String fn, Object o){
String vl = o.toString();
PrintWriter writer = new PrintWriter(fn+".txt", “UTF-8”);
writer.println(vl);
writer.close();
}

function String _ReadFromFile(String fn, String dft){
String result = dft;
try{
BufferedReader fr = new BufferedReader(new InputStreamReader(new FileInputStream(fn+".txt"), “UTF-8”));
try{
result = fr.readLine();
} finally {
fr.close();
}
} catch (IOException e) {
// e.printStackTrace();
log("File read error: "+fn);
}
return(result);
}

function Double _GetTemp(Object o){
String s = o.toString();
try{
if(s.length()>1){
return(Double.parseDouble(s.substring(0, s.length()-1)));
}else{
return(0.0);
}
} catch (NumberFormatException e) {
return(0.0);
}
}

function String _ShiftTemp(Object o, double sh){
String s = o.toString();
try{
Double t = Double.parseDouble(s.substring(0,s.length()-1)) + sh;
return(String.format("%.1f",t));
} catch (NumberFormatException e) {
return(“0.0”);
}
}

rule “Target Temp Inc”
timer(int:300ms)
when
Event(source == “TargetTemp1Inc” , value == “on”)
Event(source == “TargetTemp1”, $v: value)
then
execute.command(“TargetTemp1Inc”,“off”);
execute.command(“TargetTemp1”, _ShiftTemp($v.toString(), 0.1));
end

rule “Target Temp Dec”
timer(int:300ms)
when
Event(source == “TargetTemp1Dec” , value == “on”)
Event(source == “TargetTemp1”, $v: value)
then
execute.command(“TargetTemp1Dec”,“off”);
execute.command(“TargetTemp1”, _ShiftTemp($v.toString(), -0.1));

``

And BTW, in modeler there should be buttons, not switches? Right?

You need to define sensors in the designer for both TargetTemp1Dec an Inc. they can be of type custom and as command just use the same name, i.e. targetTemp1Dec and Inc.
Rules are triggered by sensors on LHS therefore you must to declare those sensors in the designer.

Finally I can change the value, but it changes kinda strange way - increases to value.1 only, and decreases by 1.0. Rules log says about error reading TargetTemp files.

drools.log (6.39 KB)

For some reason I think, that problem is in this code, as I haven’t changed it from Example Home, and there the degree sign is being used:

function void _WriteToFile(String fn, Object o){

String vl = o.toString();

PrintWriter writer = new PrintWriter(fn+".txt", “UTF-8”);

writer.println(vl);

writer.close();

}

function String _ReadFromFile(String fn, String dft){

String result = dft;

try{

BufferedReader fr = new BufferedReader(new InputStreamReader(new FileInputStream(fn+".txt"), “UTF-8”));

try{

result = fr.readLine();

} finally {

fr.close();

}

} catch (IOException e) {

// e.printStackTrace();

log("File read error: "+fn);

}

return(result);

}

function Double _GetTemp(Object o){

String s = o.toString();

try{

if(s.length()>1){

return(Double.parseDouble(s.substring(0, s.length()-1)));

}else{

return(0.0);

}

} catch (NumberFormatException e) {

return(0.0);

}

}

function String _ShiftTemp(Object o, double sh){

String s = o.toString();

try{

Double t = Double.parseDouble(s.substring(0,s.length()-1)) + sh;

return(String.format("%.1f",t));

} catch (NumberFormatException e) {

return(“0.0”);

}

}

``

You’ve copied functions which work for temperatures including degree character while you are not using degree symbol. You need to adopt the code. In short you don’t need to call _ShiftTemp() function because simple + and - will be enough.
Secondly, strange you are using mixed notations for floats, one as 17.9 and other as 17,9 (one with dot and one with comas). Seems like mixed coding. You need to rectify it.

Hello

I’m back. The last thing Michal said about my problems, where that the error I had were not related to my specific problem. So I knew that was the time to get a more structural approach. So I re-did all of my rules, command, sensors, and so on, in a more structural way.

So that is done.

I also updated my Java Velbus version to 1.3. And that worked without a problem. Although my only benefit would that my outdoor temp sensor would now work, and it doesnt. But that is a hardware problem and not a software problem.

But back to the issue. I would like to read the temperature, recalculate it, and send the calculated number to a dimmer. The idea (Stuart asked me) is that the temperature of the water in my floorheating will be depended on the outdoor and inside temperature. That is kind of normal in the newest heating systems, but here we have to program it ourselves.

In one of the previous post it works to get a value via rules in my dimmer.

And I can also retrieve a number from my temperaturemeters.

But I am stuck to get the one to the other.

My current rule is:

rule “Huidige temperatuur”
when
CustomState(source==“010_00_SE_TST_WnkmrSchuifpui”, $v: value)
then
double correctedValue1 = Double.parseDouble($v.toString());
// double correctedValue = (correctedValue1/1) * 5;
// execute.command(“STC”, String.format("%.1f ", correctedValue));
end

And it is this line that gives the first error:

double correctedValue1 = Double.parseDouble($v.toString());

Attached you can find the error in the log of the rules.

(2)

An unknown related problem In the velbus logs it says:

"

WARN 2017-04-12 15:09:19,511 (Velbus): Unkown command ‘246’ will be ignored
WARN 2017-04-12 15:09:24,261 (Velbus): Unkown command ‘245’ will be ignored

"

How do I know which command is which?

Thanks for

Richard

Drools error.txt (6.73 KB)

Hello Richard,

I've spoken in depth to the programmer who takes care of the Velbus implementation in OpenRemote.

He message is that the error / warning messages in the Velbus log aren't Antony to worry about.

In short, any Velbus packets that aren't understood / needed by OpenRemote will appear in that log as a warning, not an error, just a warning.

I've been seeing those exact same warnings in a few installations and I'm sure they aren't anything to worry about.

So I suspect your issue lays in the rules somewhere.

May I ask which bit of Velbus hardware you're using to pick up the outside temperature?

Cheers,

Stuart

Hi Stuart

Thank you for the quick reply.

Just to be clear. The problem after (2) in the previous message is different from the problem before the (2). You go into detail about problem after the (2)

To answer that one. I use the VMB1TS which can now be used, now I used the update 1.3 of velbus. So thank you for the reply that I do not have to worry about the two errors ( mentioned after the (2)) .
It is a hardware problem, because when I read the temperature from the software of velbus itself, it says 0,0 degrees. Which is not correct. I have to fix that separately. Maybe a wire is faulty.

If you have also an idea about the problem before the (2), I would be very interesting. It is a problem in the rules I think. Is it maybe a problem about the comma "," and the dot "." ?

Hope to hear from you

Richard

Hi Richard,

Thanks for the update.

I'm not the man to help with rules stuff, there are far better people than me :wink:

I can collate and alter, but you're asking for something I haven't seen before :frowning:

However, the issue with the lack of data from the VMB1TS ( and similar errors ) might be a really easy fix.

Have you checked the bus voltage at the VMB1TS?

You might find that it's too low.

Just a thought, have you considered using the thermostat alarm triggers within the VMB1TS to set the underfloor flow temperatures?

Two users on the Velbus forum posed a similar question, instead they​ wanted to set fan speeds.

https://forum.velbus.eu/t/0-10v-sturing-verwarming/14473/5

The trick is to setup multiple thermostat alarms, each with a set point and an atmospheric dim value.

I hope this helps.

Good luck,

Stuart

This example VLP file might help you

Pump to dimmer V4 - My prefered solution.vlp (9.1 KB)

Hi Richard,

the error is indeed caused by a wrong decimal number format. It should be with a dot, not a coma. Usually you can change it by country setting in your OS. I personally select country code as US which gives me less headache :wink:

Hi Michal

I am back.

I changed the OS to US version. Good thinking.

The result was a new error, which I could not seem to solve.

Rule:

rule “Huidige temperatuur”
when
CustomState(source==“010_00_SE_TST_WnkmrSchuifpui”,$v: value)
then
double correctedValue1 = Double.parseDouble($v.toString());
double correctedValue = (correctedValue1/1) * 1;
execute.command(“STC”, String.format("%.1f ", correctedValue));
end

And the problems is:

ERROR 2017-07-07 17:15:08,123 : [ERR 101] Line 18:1 no viable alternative at input ‘’
ERROR 2017-07-07 17:15:08,154 : [ERR 101] Line 18:3 no viable alternative at input ‘’
ERROR 2017-07-07 17:15:08,154 : [ERR 101] Line 19:1 no viable alternative at input ‘’
ERROR 2017-07-07 17:15:08,154 : [ERR 101] Line 20:1 no viable alternative at input ‘’
ERROR 2017-07-07 17:15:08,154 : [ERR 101] Line 20:3 no viable alternative at input ‘’
ERROR 2017-07-07 17:15:08,169 : [ERR 101] Line 20:5 no viable alternative at input ‘’
ERROR 2017-07-07 17:15:08,201 : [ERR 101] Line 20:7 no viable alternative at input ‘’
ERROR 2017-07-07 17:15:08,232 : [ERR 101] Line 21:1 no viable alternative at input ‘’
ERROR 2017-07-07 17:15:08,232 : [ERR 101] Line 21:3 no viable alternative at input ‘’
ERROR 2017-07-07 17:15:08,232 : [ERR 101] Line 21:5 no viable alternative at input ‘’
ERROR 2017-07-07 17:15:08,232 : [ERR 101] Line 21:7 no viable alternative at input ‘’
ERROR 2017-07-07 17:15:08,248 : [ERR 101] Line 22:1 no viable alternative at input ‘’
ERROR 2017-07-07 17:15:08,263 : [ERR 101] Line 22:3 no viable alternative at input ‘’
ERROR 2017-07-07 17:15:08,279 : [ERR 101] Line 22:5 no viable alternative at input ‘’
ERROR 2017-07-07 17:15:08,279 : [ERR 101] Line 22:7 no viable alternative at input ‘’
ERROR 2017-07-07 17:15:08,310 : [ERR 102] Line 18:2 mismatched input ‘Â’ in rule “Huidige temperatuur”

Where the special A in the last line in the PC screen is a lower case letter T.

Any suggestions

Richard

boot.log (83.2 KB)

It seems that coding of your ‘drl’ file got screwed. The best way to proceed it to make sure that it is indeed pure ASCII text, without any strange codepages.

Hi Michal

I started clean, but I found out that wasnt the problem. With the change it is somehow very critical on spaces in the rules. In all the older rules it still does not have a problem. But for this rule I am working, it does have problems. So for I know I deleted as much spaces as possible.

And that works fine.

Now I have to get the output from the temperaturesensor: 24.0

To a number without decimals. So a number between 0 en 100. Thus 24 instead of 24.0

For now, this rule works:

rule “AAA”
when
CustomState (source == “010_00_SE_TST_WnkmrSchuifpui”, $v : value);
then
double correctedValue1 = Double.parseDouble($v.toString());
double correctedValue = (correctedValue1/1) * 1;
// execute.command(“250_02_C_DL_PM”,String.format("%.1f",correctedValue));
System.out.println(correctedValue);
end

The print result is

24.0

But if also use this command in the rule:

execute.command(“250_02_C_DL_PM”,String.format("%.1f",correctedValue));

Whereas “250_02_C_DL_PM” is a command for a dimmer. ( Earlier in this discussion I already found out how to alter the dimmer via this rule.)

With that extra line in the rule, I get errors, with this:

ERROR 2017-07-09 12:40:47,046 : Invalid dynamic value supplied
java.lang.NumberFormatException: For input string: “24.0”

So, I should change the format. But somehow I don’t get to round off the number to a number without a decimal in a way that the system works.

Any suggestions?

Richard

Hi Richard.

If you're using a Velbus sensor, it's as simple as using a level sensor, rather than a custom one.

I hope this helps you.

Best wishes,

Stuart