I want to track througput of my VP connection on Draytek router using SNMP. There is VPN specific OID available on the router and when using MIB Browser I can read proper response:
Name/OID: .1.3.6.1.4.1.7367.2.1.5.1; Value (IpAddress): 37.120.156.36
Unfortunatelly SNMP sensor does some conversion of IP to string containing strange characters
- platform: snmp
name: snmp_VPN_IP
host: 192.168.52.1
baseoid: 1.3.6.1.4.1.7367.2.1.5.1
scan_interval: 10
# below lines added in desperate attempt to keep response as a string, but did not helped
value_template: >
{{ value | string }}
Which output? SNMP from router is exactly IP, as MIB browser presents. What is the format of this output when it send from router to HA I do not know, but HA sensor state is already converted to string… I checked ASCII codes (decimal) corresponding to IP address sections and this gives exactly 5 characters that HA presents as sensor state: 37 - %, 120 - x, 156 - œ, 36 - $. So HA takes each number from the strig and converts it to ASCII, omitting dots as these are apparently treated as separators.
Yet data containing alphanumerical characters (digits and dots) I’d expect to be treated literaly as string, not string with strange encoding.
Anyhow is there any way to get this properly represented as IP address in sensor state?
Good work.
SNMP can be a bit tricky to work with in that way, but it works with an incredible mount of different devices, where other methods are lacking.