Hi,
I’m using a rule to read the energy meter electric car charging station through Modbus. That gives me the total energy loaded into the car. I’m interested in the charge rate → Energy per hour. For that I do:
when
Item ModbusDataEnergyL1 changed
then
var Number ChargeRate
val oldS = previousState as Number
val newS = newState as Number
ChargeRate = (newS - oldS) * 60 / 1000
WB_ChargeRate.postUpdate(ChargeRate)
end
Now the calculation depends on the time between 2 trigger events. The Modbus Poller is set to 60sec, so that is where the 60 comes from. Yet sometimes the Modbus reading failed (communication error), so the calculation is wrong. I want to replace the 60 in the equation with the time between old and new trigger event, similar to what I do with the previousState and newState implicit variables for the meter value.
Can we get implicit variables for the trigger time too?
Or can I extract the timeBetween somehow from the Item state?
Thanks!