SNMP
A lot of Wi-Fi access points and Wi-Fi routers support the Simple Network Management Protocol (SNMP). This is a standardized method for monitoring/managing 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 Wi-Fi 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 integration 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 |
IPFire | 2.25 | 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 VR1600v | 1.3.6.1.2.1.3.1.1.2.16.1 |
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 auth_key
and priv_key
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
auth_key: AUTHPASS
priv_key: PRIVPASS
baseoid: 1.3.6.1.4.1.14988.1.1.1.2.1.1
Configuration Variables
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).
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.
See the device tracker integration page for instructions how to configure the people to be tracked.
Using templates
For incoming data, a value template translates incoming JSON or raw data to a valid payload.
Incoming payloads are rendered with possible JSON values, so when rendering, the value_json
can be used to access the attributes in a JSON based payload, otherwise the value
variable can be used for non-json based data.
Additional, the this
can be used as variables in the template. The this
attribute refers to the current entity state of the entity.
Further information about this
variable can be found in the template documentation
Example value template with json:
With given payload:
{ "state": "ON", "temperature": 21.902 }
Template {{ value_json.temperature | round(1) }}
renders to 21.9
.
Sensor
The snmp
sensor platform displays information available through the Simple Network Management Protocol (SNMP)
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
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.
The OID where the information is located. It’s advised to use the numerical notation.
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).
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.
Sets the class of the device, changing the device state and icon that is displayed on the frontend.
Defines a template for the icon of the SNMP sensor.
Defines a template for the name of the SNMP sensor.
Defines a template for the entity picture of the SNMP sensor.
The state_class of the sensor.
An ID that uniquely identifies this entity. This allows changing the name
, icon
and entity_id
from the web interface.
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
- 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
The SNMP OID which to set in order to turn the switch on and off, if different from baseoid
.
community string to use for authentication (SNMP v1 and v2c).
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.
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.
The value to write to turn on the switch, if different from payload_on
.
The value to write to turn off the switch, if different from payload_off
.
The SNMP vartype for the payload_on
and payload_off
commands as defined in RFC1902
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
Valid values for vartype
:
- Counter32
- Counter64
- Gauge32
- Integer32
- Integer
- IpAddress
- ObjectIdentifier
- OctetString
- Opaque
- TimeTicks
- Unsigned32
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
- platform: snmp
name: Enable PoE on Netgear switch port 2 using SNMP v3
host: 192.168.0.4
version: "3"
username: "myusername"
auth_key: "myauthkey"
auth_protocol: "hmac-sha"
priv_key: "myprivkey"
priv_protocol: "des"
baseoid: 1.3.6.1.4.1.4526.11.15.1.1.1.1.1.2
payload_on: 15400
payload_off: 3000
vartype: Gauge32