I’m trying to monitor my Raspberry Pis (temperature, load, drives etc.) through snmp and want to define rules (perhaps node red) and graphs (habpanel) in openhab2. Now I’ve the problem, that I’m getting temperatures as integers with values like 49926. This is obviously not the temperature of my RPI and has to be divided through 1000.
How can I do this in OpenHAB2 unless I didn’t found a way to do this on the (remote) system side.
Some bindings support a transform between raw data and channel. Unfortunately, not the SNMP binding.
openHAB profile feature allows a transform between channel and Item. Unfortunately, at the moment transform output is always in string form and cannot be linked to a Number Item. You could make a String Item take a state like “49.95” or “49.95 C” but that’s not much help if you want to compare the numeric value with some threshold to ring an alarm, for instance.
You’ll probably need a rule to parse and convert the SNMP raw data Item into a prettier virtual Number Item.
I’ve created a new item (without a thing) that can store the temperature data. After that I’ve created a rule that looks like this:
rule "SnmpConvertTemperatureOctoprint"
when
Item OctoPrintSNMPTarget_OctoprintSnmpTemperautreUnformated changed
then
var Number formatedTemperature = Math::round(((OctoPrintSNMPTarget_OctoprintSnmpTemperautreUnformated.state as Number) / 1000 * 100.0).floatValue()) / 100.0
logInfo("Snmp_Temperature.rules", "Formated temperature is: " + formatedTemperature)
OctoprintSnmpTemperautre.sendCommand(formatedTemperature)
end