This page last changed on Jan 15, 2014 by petitrabot.

Hello, I come to you for a new problem.
I have a rule that gives me the brightness in my house with a sensor.
On the result, I want to write the brightness value and "%".
To have "%" I convert in unicode, % = \u0025
My problem is that, if I write "\u0025", my rule give just the numeric value.
I have try with "\u0024", my rule give the numeric value and "&"

I give you my rule:

package org.openremote.controller.protocol;
global org.openremote.controller.statuscache.CommandFacade execute;

// For logger
import org.openremote.controller.utils.Logger;
import org.openremote.controller.Constants;
import org.openremote.controller.model.event.*
// For logger

function void log(String msg)
{
  Logger.getLogger(Constants.RUNTIME_EVENTPROCESSOR_LOG_CATEGORY + ".drools").debug(msg);
}

rule "Correct Luminosite"
when
  CustomState(source=="Sonde luminosite", $v: value)
then
  double correctedLumValue = Double.parseDouble($v.toString())/10;
  execute.command("VLUM", String.format("%.1f \u0025", correctedLumValue));
end

Thank for your help
Guillaume

You need to escape the % char. Either

\%
or
%%
should work.

Posted by aktur at Jan 15, 2014 16:02

I have try with "%%" and it's perfect

rule "Correct Luminosite"
when
  CustomState(source=="Sonde luminosite", $v: value)
then
  double correctedLumValue = Double.parseDouble($v.toString())/10;
  execute.command("VLUM", String.format("%.1f %%", correctedLumValue));
end

Thank for all MICHAL

Posted by petitrabot at Jan 15, 2014 17:27
Document generated by Confluence on Jun 05, 2016 09:39