Converting pulses to kWh

Hi guys,
I’m reading the pulses from an energy meter with Open Remote, now I need to do some math to converte from pulses to kWh, any easy way to do some basic math operations?

I tried to use rules but I dont uderstand the Drools language yet, maybe someone has a didactic material for me to learn?

Greetings from Brazil

João Pedro

https://github.com/openremote/Documentation/wiki/OpenRemote-Rules-examples

Hi,

Have you seen this list of rules examples?

There are a few with some maths in that you might be able to use as a starting point.

Good luck.

Regards from England :wink:

Stuart

I found an example which corrects temperature values and a I tried to modify it to attemd my program. And this is what I got:

rule “Pulse2kWh”

when

CustomState(Source == “Active Energy”, $v: value)

then

double kWh = Double.parseDouble($v.toString()) /100;

execute.command(“VTEMP”, String.format("%.1f kWh", kWh));

end

“Active energy” is the number of pulses I’m reading from the energy meter, “kWh” is a in-memory virtual command with command: STATUS, and address: VTEMP. I also created a custom sensor, with the custom states empty, to show the “kWh” value, which is “Active Energy”/100.

The label I linked with my sensor does not show anything, not even “N/A”.

Any ideia where my mistakes are?

Your command has a name "kWh" and this is what you should use in the execute.command(). Not the address VTEMP, unless you name the command VTEMP itself. Anyway, the simplest way is to write

   execute.command("kWh", String.format("%.1f kWh", kWh));