I’m receiving data from my Sunny Boy solarinverter through modus-tcp.
Now I would like to transform those data with javascript.
I installed the ‘JavaScript Transformation’ with Paper-UI. The javascript files are stored in /etc/openhab2/transform.
My things-file with the modbus poller:
Bridge modbus:tcp:SMAinverter [ host="192.168.178.130", port=502, id=3 ] {
// SMA SunnyBoy Device Type 30775 Actual SolarPower
Bridge poller sma30775 [ start=30775, length=4, refresh=30000, type="input", readTransform="JS(smalimit.js)" ] {
Thing data SolarPower [ readStart="30775", readValueType="int32" ]
}
// SMA SunnyBoy Device Type 30517 DC Day Yield
Bridge poller sma30517 [ start=30517, length=4, refresh=30000, type="input", readTransform="JS(divide1000.js)" ] {
Thing data DayYield [ readStart="30517", readValueType="uint64" ]
}
}
my JavaScriptfile divide1000.js
(function(i) {
return parseFloat(i) / 1000;
})(input)
my JavaScript file smalimit.js
(function(i) {
if(i < 0) return "UNDEF";
return parseFloat(i) / 1000;
})(input)
I already restarted the services with the karaf-console.
Unfortunately the transformation proces still doesn’t work. What am I doing wrong ?