- Platform information:
- OS: Windows 10
- Java Runtime Environment: zulu 11.43.5
- Openhab 3.0.0
Hi All
Looking for some advice as I have now upgraded to OH 3.0.
I use the SNMP Binding to read values from my UPS using SNMP OID, and example of a channel is as follows:
- id: UPS_Batt_Voltage
channelTypeUID: snmp:number
label: UPS Batt Voltage
description: null
configuration:
mode: READ
datatype: INT32
oid: .1.3.6.1.4.1.21111.1.1.3.5.0
The result from this is in this example 816, however the UPS Battery Voltage is actually 81.6V (not 816V). The same situation exist for most of the information retrieved via SNMP, needing either a /10 or /100 to correct. So I use a rule to divide the value by 10 as follows:
rule "UPS_Batt_Voltage"
when
Item UPS_SNMP_UPSBattVoltage received update
then
{
val trans = (UPS_SNMP_UPSBattVoltage.state as Number)/10
UPS_SNMP_UPSBattVoltage_Fix.postUpdate(trans)
}
end
The result of this is that UPS_SNMP_UPSBattVoltage_Fix has a value of 81.60000000
There are two downsides to this that I would like to resolve, but have not been able to find a solution that I can implement as a non coder.
Firstly this requires a second Item so carry the “Fixed” value - I seem to recall reading somewhere that the value could be corrected on the fly, but I have not been able to find how to do this. I have searched TRANSFORM etc. with no luck.
Second is that the resultant value is something like 81.60000000, where it would be more meaningful to have 81.60 (limit to 2 decimal places).
Any advise on what to look at would be appreciated?
Mark