Skip to content

OtisPresley/snmp-switch-manager

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

662 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

SNMP Switch Manager: Home Assistant Custom Integration

Home Assistant HACS Badge HA installs License: MIT hassfest HACS CI

SNMP Switch Manager discovers an SNMP-enabled switch and exposes each port to Home Assistant with live status, descriptions, and administrative control. Pair it with the included Lovelace card for a rich dashboard visualisation of your hardware.


Table of Contents


Highlights

  • πŸ” Automatic discovery of port count, speed, VLAN ID (PVID), description, and operational status via SNMP (v2c or v3)
  • πŸ”„ Background polling that keeps Home Assistant entities and attributes in sync with live switch data
  • 🎚️ One switch entity per interface for toggling administrative state (up/down)
  • 🏷️ Service for updating the interface alias (ifAlias) directly from Home Assistant
  • πŸ–ΌοΈ Lovelace card that mirrors the physical switch layout with colour-coded port status and quick actions
  • πŸ“Ά Optional per-port bandwidth monitoring (RX / TX throughput & totals) with support for attributes or dedicated sensors
  • 🌑️ Environment monitoring (CPU, memory, system/chassis temperature) with support for attributes or dedicated sensors
  • ⚑ Power over Ethernet (PoE) monitoring (used and remaining power budget) with support for attributes or dedicated sensors

Requirements

  • Home Assistant 2025.11.2 or newer (recommended)
  • A switch (or SNMP-enabled network device) reachable via SNMP (UDP/161)
  • SNMP credentials with read access to interface tables
  • Write access is optional but required for:
    • Updating ifAlias (port description)
    • Toggling administrative state (if supported by the device)
  • pysnmp 7.x (the integration installs it automatically when needed)

Installation

HACS (recommended)

You can install this integration directly from HACS:

Open your Home Assistant instance and show the repository inside the Home Assistant Community Store.

After installation, restart Home Assistant and add the integration:

Open your Home Assistant instance and add this integration.


Manual steps (if you prefer not to use the buttons)

  1. In Home Assistant, open HACS β†’ Integrations.
  2. Click Explore & Download Repositories, search for SNMP Switch Manager, then click Download.
  3. Restart Home Assistant.
  4. Go to Settings β†’ Devices & Services β†’ Add Integration β†’ SNMP Switch Manager.

Manual install

  1. Copy the folder custom_components/snmp_switch_manager into your HA config/custom_components directory.
  2. Restart Home Assistant.
  3. Go to Settings β†’ Devices & Services β†’ Add Integration β†’ SNMP Switch Manager.

Documentation

Comprehensive documentation for SNMP Switch Manager is available in the GitHub Wiki.

The Wiki includes:

  • Installation and configuration guidance
  • Attributes vs Sensors explained
  • Diagnostics and PoE behavior
  • Lovelace card usage and customization
  • Supported switches and limitations
  • Troubleshooting and FAQ

πŸ‘‰ Read the full documentation:
https://github.com/OtisPresley/snmp-switch-manager/wiki


Services

SNMP Switch Manager provides Home Assistant services for advanced use cases, such as interacting with or refreshing switch-related data.

These services are optional and are typically used by:

  • Advanced users
  • Automations
  • Scripts

Most users will not need to use services directly.

πŸ‘‰ See the GitHub Wiki for full usage guidance and examples: https://github.com/OtisPresley/snmp-switch-manager/wiki

Example: Update a port description

Use the snmp_switch_manager.set_port_description service to change an interface alias:

service: snmp_switch_manager.set_port_description
data:
  entity_id: switch_switch_study_gi1_0_5
  description: Uplink to router

Toggle administrative state

The state of each port entity reflects the interface's administrative status. Turning it on sets the port to up; turning it off sets it to down. Entity attributes include both administrative and operational status direct from SNMP. Entity attributes include administrative status, operational status, port speed, VLAN ID (PVID), and IP configuration when available.


Troubleshooting

⚠️ Startup Warning Messages (pysnmp)

During Home Assistant startup, you may see one or two warning messages similar to:

Detected blocking call to listdir/open inside the event loop by custom integration 'snmp_switch_manager'

What this means

These warnings originate from pysnmp, the upstream SNMP library used by this integration.
On first use, pysnmp lazily loads a small number of internal MIB files from disk, which Home Assistant flags as a potential blocking operation.

Impact

  • βœ”οΈ No functional impact
  • βœ”οΈ No data loss
  • βœ”οΈ No performance degradation during normal operation
  • βœ”οΈ Typically occurs only once at startup

The integration continues to operate asynchronously and efficiently after initialization.

Why this is not suppressed

Suppressing these warnings would require moving all SNMP operations into background threads, which significantly increases startup time and slows down option changes on large switches. To preserve performance and responsiveness, the integration intentionally keeps the fast async execution path.

Summary

If you see these warnings:

  • They are expected
  • They are safe to ignore
  • No action is required

This behavior is tracked upstream in pysnmp and Home Assistant.

Common Issues

  • Ports missing: Ensure your SNMP credentials permit reads on the interface tables (ifDescr, ifSpeed, ifOperStatus).
  • Description updates fail: Confirm your SNMP credentials have write permission for ifAlias (1.3.6.1.2.1.31.1.1.1.18).
  • Unexpected speeds: Some devices report zero or vendor-specific rates for unused interfaces; check the device UI to confirm raw SNMP data.

Support

If your switch does not display correctly, then the integration may need device-specific support added for it.

Please open an issue with:

  • A text file attachment containing snmpwalk output against your device (SNMP v2c or SNMP v3)
  • Any necessary screenshots
  • A description of what is incorrect and what it should look like

Tip: If you want port descriptions and administrative toggles to work, your SNMP credentials must allow writes to the required OIDs (device-dependent).

Supported Switches

πŸ‘‰ Read the full documentation:
https://github.com/OtisPresley/snmp-switch-manager/wiki

Open an Issue

  • Open an issue on the GitHub tracker if you run into problems or have feature requests.
  • Contributions and feedback are welcome!

If you find this integration useful and want to support development, you can:

Buy Me a Coffee Donate via PayPal

About

A Home Assistant integration using SNMP to manage a switch

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages