I need some help configuring SNMP float fields using the SNMP 2 binding. The fields in question are defined as float fields. Based on the documentation I believe that I am supposed to define the thing and item as strings, adding datatype=“FLOAT” to the thing definition. When I save the .thing file the following warning is displayed in the log regardless of if the item is defined as a number or a string. (Synology’s documentation states that all SNMP OIDs are read-only.)
2021-06-11 23:30:23.920 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'Diskstation.items'
2021-06-11 23:30:24.112 [WARN ] [ding.snmp.internal.SnmpTargetHandler] - can't process command REFRESH to snmp:target:Diskstation:UPS_Load: no writable channel found
Changing the configuration from string to number eliminates the warning message in the log, but the value is always NULL.
MIB Browser confirms that the Diskstation returns the correct value in the field (0x9F 78 04 41 30 00 00 for 11.0 percent load).
How can I configure these float fields?
Thing definition
Type string: UPS_Load [oid=".1.3.6.1.4.1.6574.4.2.12.1.0", mode="READ", datatype="FLOAT"]
Thank you for your help and sorry for the late reply – it was after 1am when I made the previous replay and I needed some sleep. The link to the MIB files is:
I didn’t mention it before, but all four of the Float fields from the Synology have the same issue.
Type string : UPS_Load [oid=".1.3.6.1.4.1.6574.4.2.12.1.0", mode="READ", datatype="FLOAT"]
Type number : UPS_Charge [oid=".1.3.6.1.4.1.6574.4.3.1.1.0", mode="READ", datatype="FLOAT"]
Type number : UPS_Warning [oid=".1.3.6.1.4.1.6574.4.3.1.4.0", mode="READ", datatype="FLOAT"]
Type number : UPS_Type [oid=".1.3.6.1.4.1.6574.4.3.12.0", mode="READ", datatype="FLOAT"]
If I’m not mistaken, your issue is that opaque value handling is not supported by the openHAB SNMP binding.
The MIB imports type Float from NET-SNMP-TC and that reads:
Float ::= TEXTUAL-CONVENTION
STATUS current
DESCRIPTION
"A single precision floating-point number. The semantics
and encoding are identical for type 'single' defined in
IEEE Standard for Binary Floating-Point,
ANSI/IEEE Std 754-1985.
The value is restricted to the BER serialization of
the following ASN.1 type:
FLOATTYPE ::= [120] IMPLICIT FloatType
(note: the value 120 is the sum of '30'h and '48'h)
The BER serialization of the length for values of
this type must use the definite length, short
encoding form.
For example, the BER serialization of value 123
of type FLOATTYPE is '9f780442f60000'h. (The tag
is '9f78'h; the length is '04'h; and the value is
'42f60000'h.) The BER serialization of value
'9f780442f60000'h of data type Opaque is
'44079f780442f60000'h. (The tag is '44'h; the length
is '07'h; and the value is '9f780442f60000'h.)"
SYNTAX Opaque (SIZE (7))
I guess I don’t understand the formatting. While the MIB Browser says the type is Opaque it looks to me like the actual hex value that it displays is in BER format.
Are you aware of any work-arounds that I could use, maybe JavaScript or something?