Hello everyone!
I’ve got a ModBus-connected energy meter and trying to set it up. According to the documentation, raw values from registers must be multiplied by a given constant (constants differ for different kinds of values). Is there a simple way to set this up, or do i have to use Javascript transformation and code my multiplications by hands ?
You need to use javascript transformation as far as I know… Thats how I´m doing it:
thing setup:
// SMA Inverter Yield
Bridge poller Yield [ start=30517, length=16, refresh=5000, type="input" ] {
Thing data Day_Yield [ readStart="30517", readValueType="int64", readTransform="JS(divide1000.js)" ]
Thing data Total_Yield [ readStart="30529", readValueType="int32", readTransform="JS(divide1000.js)" ]
}
script for divide in the above thing
// Wrap everything in a function
(function(i) {
return parseFloat(i) / 1000;
})(input)
// input variable contains data passed by openhab
Script if you want to multiply:
// Wrap everything in a function
(function(i) {
return Math.round(parseFloat(i, 10) * 1000);
})(input)
// input variable contains data passed by openhab
Well, that’s what i did. So far not only i need it. Should the “Coefficient” transformation be added to OpenHAB 3 ?
I have no idea of OH3