SNMP


A lot of WiFi access points and WiFi routers support the Simple Network Management Protocol (SNMP). This is a standardized method for monitoring/manageing network connected devices. SNMP uses a tree-like hierarchy where each node is an object. Many of these objects contain (live) lists of instances and metrics, like network interfaces, disks, and WiFi registrations.

There is currently support for the following device types within Home Assistant:

This device tracker needs SNMP to be enabled on the router. It could be that you need to install the SNMP support manually.

Presence Detection

The following OID examples pull the current MAC Address table from a router. This reflects all recent devices seen on the network. However, since devices are not removed until they time out, this is less effective for device tracker component page than desirable. It is recommended to use Ping or Nmap instead.

Brand Device/Firmware OID
Aerohive AP230 1.3.6.1.4.1.26928.1.1.1.2.1.2.1.1
Apple Airport Express (2nd gen.) 7.6.9 1.3.6.1.2.1.3.1.1.2 or 1.3.6.1.2.1.4.22.1.2
Aruba IAP325 on AOS 6.5.4.8 1.3.6.1.4.1.14823.2.3.3.1.2.4.1.1
BiPAC 7800DXL Firmware 2.32e 1.3.6.1.2.1.17.7.1.2.2.1.1
DD-WRT unknown version/model 1.3.6.1.2.1.4.22.1.2
Mikrotik unknown RouterOS version/model 1.3.6.1.4.1.14988.1.1.1.2.1.1
Mikrotik RouterOS 6.x on RB2011 1.3.6.1.2.1.4.22.1.2
OpenWrt Chaos Calmer 15.05 1.3.6.1.2.1.4.22.1.2
OPNSense 19.1 1.3.6.1.2.1.4.22.1.2
pfSense 2.2.4 1.3.6.1.2.1.4.22.1.2
Ruckus ZoneDirector 9.13.3 1.3.6.1.4.1.25053.1.2.2.1.1.3.1.1.1.6
TP-Link Archer VR2600v 1.3.6.1.2.1.3.1.1.2.19.1
TP-Link Archer VR600 1.3.6.1.2.1.3.1.1.2
Ubiquiti Edgerouter Lite v1.9.0 1.3.6.1.2.1.4.22.1.2

To use the SNMP version 1 or 2c platform in your installation, add the following to your configuration.yaml file:

# Example configuration.yaml entry for SNMP version 1 or 2c
device_tracker:
  - platform: snmp
    host: 192.168.1.1
    community: public
    baseoid: 1.3.6.1.4.1.14988.1.1.1.2.1.1

If you want to use encryption, you must enable SNMP version 3 by adding authkey and privkey variables and enabling SNMP version 3 on your router. Currently only SHA1 is supported for authentication and AES for encryption. Example of SNMPv3 configuration:

# Example configuration.yaml entry for SNMP version 3
device_tracker:
  - platform: snmp
    host: 192.168.1.1
    community: USERNAME
    authkey: AUTHPASS
    privkey: PRIVPASS
    baseoid: 1.3.6.1.4.1.14988.1.1.1.2.1.1

Configuration Variables

host

(string)(Required)The IP address of the router, e.g., 192.168.1.1.

community

(string)(Required)The SNMP community which is set for the device. Most devices have a default community set to public with read-only permission (which is sufficient).

baseoid

(string)(Required)The OID prefix where wireless client registrations can be found, usually vendor specific. It’s advised to use the numerical notation. To find this base OID, check vendor documentation or check the MIB file for your device.

authkey

(string)(Inclusive)Authentication key for SNMPv3. Variable privkey must also be set.

privkey

(string)(Inclusive)Privacy key SNMPv3. Variable authkey must also be set.

See the device tracker component page for instructions how to configure the people to be tracked.

Sensor

The snmp sensor platform displays information available through the Simple Network Management Protocol (SNMP). SNMP uses a tree-like hierarchy where each node is an object, and is mainly supported by network-oriented devices such as routers, modems, and printers.

To enable this sensor in your installation, add the following to your configuration.yaml file:

# Example configuration.yaml entry
sensor:
  - platform: snmp
    host: 192.168.1.32
    baseoid: 1.3.6.1.4.1.2021.10.1.3.1

Configuration Variables

host

(string)(Optional)The IP address of your host, e.g., 192.168.1.32.

Default value: localhost

baseoid

(string)(Required)The OID where the information is located. It’s advised to use the numerical notation.

port

(string)(Optional)The SNMP port of your host.

Default value: 161

community

(string)(Optional)The SNMP community which is set for the device for SNMP v1 and v2c. Most devices have a default community set to public with read-only permission (which is sufficient).

Default value: public

username

(string)(Optional)Username to use for authentication.

Default value:

auth_key

(string)(Optional)Authentication key to use for SNMP v3.

Default value: no key

auth_protocol

(string)(Optional)Authentication protocol to use for SNMP v3.

Default value: none

priv_key

(string)(Optional)Privacy key to use for SNMP v3.

Default value: no key

priv_protocol

(string)(Optional)Privacy protocol to use for SNMP v3.

Default value: none

version

(string)(Optional)Version of SNMP protocol, 1, 2c or 3. Version 2c or higher is needed to read data from 64-bit counters.

Default value: 1

name

(string)(Optional)Name of the SNMP sensor.

unit_of_measurement

(string)(Optional)Defines the unit of measurement of the sensor, if any.

value_template

(template)(Optional)Defines a template to parse the value.

accept_errors

(string)(Optional)Determines whether the sensor should start and keep working even if the SNMP host is unreachable or not responding. This allows the sensor to be initialized properly even if, for example, your printer is not on when you start Home Assistant.

Default value: false

default_value

(string)(Optional)Determines what value the sensor should take if accept_errors is set and the host is unreachable or not responding. If not set, the sensor will have value unknown in case of errors.

Valid values for auth_protocol:

  • none
  • hmac-md5
  • hmac-sha
  • hmac128-sha224
  • hmac192-sha256
  • hmac256-sha384
  • hmac384-sha512

Valid values for priv_protocol:

  • none
  • des
  • 3des-ede
  • aes-cfb-128
  • aes-cfb-192
  • aes-cfb-256

Finding OIDs

OIDs may vary on different systems because they are vendor-specific. Besides the device’s manual, the OID Repository is a good place to start if you are looking for OIDs. As an example, the following OIDs are for the load of a Linux system.

  • 1 minute Load: 1.3.6.1.4.1.2021.10.1.3.1
  • 5 minute Load: 1.3.6.1.4.1.2021.10.1.3.2
  • 15 minute Load: 1.3.6.1.4.1.2021.10.1.3.3

There is a large amount of tools available to work with SNMP. snmpwalk let you easily retrieve the value of an OID.

$ snmpwalk -Os -c public -v 2c 192.168.1.32 1.3.6.1.4.1.2021.10.1.3.1
laLoad.1 = STRING: 0.19

Examples

Printer uptime minutes

According to the most common SNMP standard, the uptime of a device is accessible under OID 1.3.6.1.2.1.1.3.0. The value represented using a format called TimeTicks, in units of hundredths of a second.

To create a sensor that displays the uptime for your printer in minutes, you can use this configuration:

# Example configuration.yaml entry
sensor:
  - platform: snmp
    name: 'Printer uptime'
    host: 192.168.2.21
    baseoid: 1.3.6.1.2.1.1.3.0
    accept_errors: true
    unit_of_measurement: 'minutes'
    value_template: '{{((value | int) / 6000) | int}}'

The accept_errors option will allow the sensor to work even if the printer is not on when Home Assistant is first started: the sensor will just display a - instead of a minute count.

The value_template option converts the original value to minutes.

Switch

The snmp switch platform allows you to control SNMP-enabled equipment.

Currently, only SNMP OIDs that accept integer values are supported. SNMP v1, v2c and v3 are supported.

To use an SNMP switch in your installation:

# Example configuration.yaml entry:
switch:
  - platform: snmp
    host: 192.168.0.2
    baseoid: 1.3.6.1.4.1.19865.1.2.1.4.0

Configuration Variables

baseoid

(string)(Required)The SNMP BaseOID which to poll for the state of the switch.

command_oid

(string)(Optional)The SNMP OID which to set in order to turn the switch on and off, if different from baseoid.

host

(string)(Optional)The IP/host which to control.

Default value: localhost

port

(string)(Optional)The port on which to communicate.

Default value: 161

community

(string)(Optional)community string to use for authentication (SNMP v1 and v2c).

Default value: private

username

(string)(Optional)Username to use for authentication.

Default value:

auth_key

(string)(Optional)Authentication key to use for SNMP v3.

Default value: no key

auth_protocol

(string)(Optional)Authentication protocol to use for SNMP v3.

Default value: none

priv_key

(string)(Optional)Privacy key to use for SNMP v3.

Default value: no key

priv_protocol

(string)(Optional)Privacy protocol to use for SNMP v3.

Default value: none

version

(string)(Optional)SNMP version to use - either 1, 2c or 3.

Default value: 1

payload_on

(string)(Optional)What return value represents an On state for the switch. The same value is used in writes to turn on the switch if command_payload_on is not set.

Default value: 1

payload_off

(string)(Optional)What return value represents an Off state for the switch. The same value is used in writes to turn off the switch if command_payload_off is not set.

Default value: 0

command_payload_on

(string)(Optional)The value to write to turn on the switch, if different from payload_on.

command_payload_off

(string)(Optional)The value to write to turn off the switch, if different from payload_off.

You should check with your device’s vendor to find out the correct BaseOID and what values turn the switch on and off.

Valid values for auth_protocol:

  • none
  • hmac-md5
  • hmac-sha
  • hmac128-sha224
  • hmac192-sha256
  • hmac256-sha384
  • hmac384-sha512

Valid values for priv_protocol:

  • none
  • des
  • 3des-ede
  • aes-cfb-128
  • aes-cfb-192
  • aes-cfb-256

Complete examples:

switch:
  - platform: snmp
    name: SNMP v1 switch
    host: 192.168.0.2
    community: private
    baseoid: 1.3.6.1.4.1.19865.1.2.1.4.0
    payload_on: 1
    payload_off: 0

  - platform: snmp
    name: SNMP v3 switch
    host: 192.168.0.3
    version: '3'
    username: 'myusername'
    auth_key: 'myauthkey'
    auth_protocol: 'hmac-sha'
    priv_key: 'myprivkey'
    priv_protocol: 'aes-cfb-128'
    baseoid: 1.3.6.1.4.1.19865.1.2.1.4.0
    payload_on: 1
    payload_off: 0