Hello people,
I’m trying to add ups via snmp addin to OpenHAB (I don’t want to use NUT or other intermediate apps).
The ups is eaton (via network-card-ms), but it should be comparable to all other ups-es.
This ups can use V1 and V3 protocol, so I choose V1 (as addon does not support V3). The OID 1.3.6.1.2.1.33.2 is trap for upsTrapOnBattery - that’s what i’m trying to catch.
This is tcpdump of snmp message when ups switches to battery:
Trap(52) E:33.2 192.168.2.244 enterpriseSpecific s=4 12154446 system.sysUptime.0=12154446 1.3.6.1.2.1.33.1.6.2.1.1.0 = 5 1.3.6.1.2.1.33.1.6.2.1.2.0 = 1.3.6.1.2.1.33.1.6.3.6
Please ignore other variables (it is alarm type and name).
Here is OpenHAB SNMP log:
[TRACE] [nding.snmp.internal.SnmpTargetHandler] - snmp:target:ups received trap CommandResponderEvent[securityModel=1, securityLevel=1, maxSizeResponsePDU=65535, pduHandle=PduHandle[0], stateReference=StateReference[msgID=0,pduHandle=PduHandle[0],securityEngineID=null,securityModel=null,securityName=public,securityLevel=1,contextEngineID=null,contextName=null,retryMsgIDs=null], pdu=V1TRAP[reqestID=0,timestamp=1 day, 6:48:22.12,enterprise=1.3.6.1.2.1.33.2,genericTrap=6,specificTrap=4, VBS[1.3.6.1.2.1.1.3.0 = 1 day, 6:48:22.12; 1.3.6.1.2.1.33.1.6.2.1.1.0 = 5; 1.3.6.1.2.1.33.1.6.2.1.2.0 = 1.3.6.1.2.1.33.1.6.3.6]], messageProcessingModel=0, securityName=public, processed=false, peerAddress=192.168.2.244/33422, transportMapping=org.snmp4j.transport.DefaultUdpTransportMapping@105c26c, tmStateReference=null]
[DEBUG] [nding.snmp.internal.SnmpTargetHandler] - received value 5 for unknown OID 1.3.6.1.2.1.33.1.6.2.1.1.0, skipping
The enterprise oid & value are received by snmp addon, but they are ignored further down the message queue:
This is from SnmpTargetHandler.java
if ((pdu.getType() == PDU.TRAP || pdu.getType() == PDU.V1TRAP) && config.community.equals(community)
&& targetAddressString.equals(address)) {
pdu.getVariableBindings().forEach(variable -> {
OID oid = variable.getOid();
Variable value = variable.getVariable();
updateChannels(oid, value, trapChannelSet);
});
So here is my question/concern: Am I doing something wrong (i have this OID in .things file, but according to the code above, OH ignores enterprise OID), or i should change snmp source code, in order to include enterprise OID in updateChannels? I think that SNMP binding is not using PDUv1 class (but PDU), so code change might not be so trivial?
Any other possibilities to catch upsTrapOnBattery?