Repository: home-assistant/core
Pull request: Fix snmp doing blocking I/O in the event loop
## Proposed change
<!--
  Describe the big picture of your changes here to communicate to the
  maintainers why we should accept this pull request. If it fixes a bug
  or resolves a feature request, be sure to link to that issue in the
  additional information section.
-->
Fix snmp doing blocking I/O in the event loop to load MIB data.


## Type of change
<!--
  What type of change does your PR introduce to Home Assistant?
  NOTE: Please, check only 1! box!
  If your PR requires multiple boxes to be checked, you'll most likely need to
  split it into multiple PRs. This makes things easier and faster to code review.
-->

- [ ] Dependency upgrade
- [x] Bugfix (non-breaking change which fixes an issue)
- [ ] New integration (thank you!)
- [ ] New feature (which adds functionality to an existing integration)
- [ ] Deprecation (breaking change to happen in the future)
- [ ] Breaking change (fix/feature causing existing functionality to break)
- [ ] Code quality improvements to existing code or addition of tests

## Additional information
<!--
  Details are important, and help maintainers processing your PR.
  Please be sure to fill out additional details, if applicable.
-->

- This PR fixes or closes issue: fixes #118426
- This PR is related to issue: #117601
- Link to documentation pull request: 

## Checklist
<!--
  Put an `x` in the boxes that apply. You can also fill these out after
  creating the PR. If you're unsure about any of them, don't hesitate to ask.
  We're here to help! This is simply a reminder of what we are going to look
  for before merging your code.
-->

- [x] The code change is tested and works locally.
- [ ] Local tests pass. **Your PR cannot be merged unless tests pass**
- [ ] There is no commented out code in this PR.
- [ ] I have followed the [development checklist][dev-checklist]
- [ ] I have followed the [perfect PR recommendations][perfect-pr]
- [ ] The code has been formatted using Ruff (`ruff format homeassistant tests`)
- [x] Tests have been added to verify that the new code works.

If user exposed functionality or configuration variables are added/changed:

- [ ] Documentation added/updated for [www.home-assistant.io][docs-repository]

If the code communicates with devices, web services, or third-party tools:

- [ ] The [manifest file][manifest-docs] has all fields filled out correctly.  
      Updated and included derived files by running: `python3 -m script.hassfest`.
- [ ] New or updated dependencies have been added to `requirements_all.txt`.  
      Updated by running `python3 -m script.gen_requirements_all`.
- [ ] For the updated dependencies - a link to the changelog, or at minimum a diff between library versions is added to the PR description.
- [ ] Untested files have been added to `.coveragerc`.

<!--
  This project is very active and we have a high turnover of pull requests.

  Unfortunately, the number of incoming pull requests is higher than what our
  reviewers can review and merge so there is a long backlog of pull requests
  waiting for review. You can help here!
  
  By reviewing another pull request, you will help raise the code quality of
  that pull request and the final review will be faster. This way the general
  pace of pull request reviews will go up and your wait time will go down.
  
  When picking a pull request to review, try to choose one that hasn't yet
  been reviewed.

  Thanks for helping out!
-->

To help with the load of incoming pull requests:

- [ ] I have reviewed two other [open pull requests][prs] in this repository.

[prs]: https://github.com/home-assistant/core/pulls?q=is%3Aopen+is%3Apr+-author%3A%40me+-draft%3Atrue+-label%3Awaiting-for-upstream+sort%3Acreated-desc+review%3Anone+-status%3Afailure

<!--
  Thank you for contributing <3

  Below, some useful links you could explore:
-->
[dev-checklist]: https://developers.home-assistant.io/docs/development_checklist/
[manifest-docs]: https://developers.home-assistant.io/docs/creating_integration_manifest/
[quality-scale]: https://developers.home-assistant.io/docs/integration_quality_scale_index/
[docs-repository]: https://github.com/home-assistant/home-assistant.io
[perfect-pr]: https://developers.home-assistant.io/docs/review-process/#creating-the-perfect-pr


Problem statement:
Detected blocking call to open with args ('/usr/local/lib/python3.12/site-packages/pysnmp/smi/mibs/instances/__SNMPv2-MIB.py', 'r')
### The problem

Since Home Assistant 2024.6.0b0, the below warnings appear. It is unclear to me which integration is causing this.

### What version of Home Assistant Core has the issue?

core-2024.6.0b0

### What was the last working version of Home Assistant Core?

core-2024.5.5

### What type of installation are you running?

Home Assistant OS

### Integration causing the issue

_No response_

### Link to integration documentation on our website

_No response_

### Diagnostics information

_No response_

### Example YAML snippet

_No response_

### Anything in the logs that might be useful for us?

```txt
Logger: homeassistant.util.loop
Source: util/loop.py:55
First occurred: 21:21:45 (1 occurrences)
Last logged: 21:21:45

Detected blocking call to open with args ('/usr/local/lib/python3.12/site-packages/pysnmp/smi/mibs/instances/__SNMPv2-MIB.py', 'r') in /usr/local/lib/python3.12/site-packages/pysnmp/smi/builder.py, line 256: fp = open(p, mode) inside the event loop
```


### Additional information

_No response_

Hints from issue discussion:
Looking at the name of the package I would guess `snmp`
Could be, but i've not installed the snmp integration.
Might have the same root cause as this one? https://github.com/home-assistant/core/issues/118424

Hey there @nmaggioni, mind taking a look at this issue as it has been labeled with an integration (`snmp`) you are listed as a [code owner](https://github.com/home-assistant/core/blob/dev/CODEOWNERS#L1293) for? Thanks!

<details>
<summary>Code owner commands</summary>


Code owners of `snmp` can trigger bot actions by commenting:

- `@home-assistant close` Closes the issue.
- `@home-assistant rename Awesome new title` Renames the issue.
- `@home-assistant reopen` Reopen the issue.
- `@home-assistant unassign snmp` Removes the current integration label and assignees on the issue, add the integration domain after the command.
- `@home-assistant add-label needs-more-information` Add a label (needs-more-information, problem in dependency, problem in custom component) to the issue.
- `@home-assistant remove-label needs-more-information` Remove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.

</details>


<sub><sup>(message by CodeOwnersMention)</sup></sub>

---

[snmp documentation](https://www.home-assistant.io/integrations/snmp)
[snmp source](https://github.com/home-assistant/core/tree/dev/homeassistant/components/snmp)
<sub><sup>(message by IssueLinks)</sup></sub>

Commit message: testing fixes

Patch to review:
diff --git a/homeassistant/components/snmp/device_tracker.py b/homeassistant/components/snmp/device_tracker.py
index 5d4f9e5e0d935b..d336838117f864 100644
--- a/homeassistant/components/snmp/device_tracker.py
+++ b/homeassistant/components/snmp/device_tracker.py
@@ -4,14 +4,11 @@
 
 import binascii
 import logging
+from typing import TYPE_CHECKING
 
 from pysnmp.error import PySnmpError
 from pysnmp.hlapi.asyncio import (
     CommunityData,
-    ContextData,
-    ObjectIdentity,
-    ObjectType,
-    SnmpEngine,
     Udp6TransportTarget,
     UdpTransportTarget,
     UsmUserData,
@@ -43,6 +40,7 @@
     DEFAULT_VERSION,
     SNMP_VERSIONS,
 )
+from .util import RequestArgsType, async_create_request_cmd_args
 
 _LOGGER = logging.getLogger(__name__)
 
@@ -62,7 +60,7 @@ async def async_get_scanner(
 ) -> SnmpScanner | None:
     """Validate the configuration and return an SNMP scanner."""
     scanner = SnmpScanner(config[DOMAIN])
-    await scanner.async_init()
+    await scanner.async_init(hass)
 
     return scanner if scanner.success_init else None
 
@@ -99,33 +97,29 @@ def __init__(self, config):
             if not privkey:
                 privproto = "none"
 
-            request_args = [
-                SnmpEngine(),
-                UsmUserData(
-                    community,
-                    authKey=authkey or None,
-                    privKey=privkey or None,
-                    authProtocol=authproto,
-                    privProtocol=privproto,
-                ),
-                target,
-                ContextData(),
-            ]
+            self._auth_data = UsmUserData(
+                community,
+                authKey=authkey or None,
+                privKey=privkey or None,
+                authProtocol=authproto,
+                privProtocol=privproto,
+            )
         else:
-            request_args = [
-                SnmpEngine(),
-                CommunityData(community, mpModel=SNMP_VERSIONS[DEFAULT_VERSION]),
-                target,
-                ContextData(),
-            ]
-
-        self.request_args = request_args
+            self._auth_data = CommunityData(
+                community, mpModel=SNMP_VERSIONS[DEFAULT_VERSION]
+            )
+
+        self._target = target
+        self.request_args: RequestArgsType | None = None
         self.baseoid = baseoid
         self.last_results = []
         self.success_init = False
 
-    async def async_init(self):
+    async def async_init(self, hass: HomeAssistant) -> None:
         """Make a one-off read to check if the target device is reachable and readable."""
+        self.request_args = await async_create_request_cmd_args(
+            hass, self._auth_data, self._target, self.baseoid
+        )
         data = await self.async_get_snmp_data()
         self.success_init = data is not None
 
@@ -156,12 +150,18 @@ async def _async_update_info(self):
     async def async_get_snmp_data(self):
         """Fetch MAC addresses from access point via SNMP."""
         devices = []
+        if TYPE_CHECKING:
+            assert self.request_args is not None
 
+        engine, auth_data, target, context_data, object_type = self.request_args
         walker = bulkWalkCmd(
-            *self.request_args,
+            engine,
+            auth_data,
+            target,
+            context_data,
             0,
             50,
-            ObjectType(ObjectIdentity(self.baseoid)),
+            object_type,
             lexicographicMode=False,
         )
         async for errindication, errstatus, errindex, res in walker:
diff --git a/homeassistant/components/snmp/sensor.py b/homeassistant/components/snmp/sensor.py
index 939cb13ae35373..0e5b215dcd4e29 100644
--- a/homeassistant/components/snmp/sensor.py
+++ b/homeassistant/components/snmp/sensor.py
@@ -11,10 +11,6 @@
 import pysnmp.hlapi.asyncio as hlapi
 from pysnmp.hlapi.asyncio import (
     CommunityData,
-    ContextData,
-    ObjectIdentity,
-    ObjectType,
-    SnmpEngine,
     Udp6TransportTarget,
     UdpTransportTarget,
     UsmUserData,
@@ -71,6 +67,7 @@
     MAP_PRIV_PROTOCOLS,
     SNMP_VERSIONS,
 )
+from .util import async_create_request_cmd_args
 
 _LOGGER = logging.getLogger(__name__)
 
@@ -119,7 +116,7 @@ async def async_setup_platform(
     host = config.get(CONF_HOST)
     port = config.get(CONF_PORT)
     community = config.get(CONF_COMMUNITY)
-    baseoid = config.get(CONF_BASEOID)
+    baseoid: str = config[CONF_BASEOID]
     version = config[CONF_VERSION]
     username = config.get(CONF_USERNAME)
     authkey = config.get(CONF_AUTH_KEY)
@@ -145,27 +142,18 @@ async def async_setup_platform(
             authproto = "none"
         if not privkey:
             privproto = "none"
-
-        request_args = [
-            SnmpEngine(),
-            UsmUserData(
-                username,
-                authKey=authkey or None,
-                privKey=privkey or None,
-                authProtocol=getattr(hlapi, MAP_AUTH_PROTOCOLS[authproto]),
-                privProtocol=getattr(hlapi, MAP_PRIV_PROTOCOLS[privproto]),
-            ),
-            target,
-            ContextData(),
-        ]
+        auth_data = UsmUserData(
+            username,
+            authKey=authkey or None,
+            privKey=privkey or None,
+            authProtocol=getattr(hlapi, MAP_AUTH_PROTOCOLS[authproto]),
+            privProtocol=getattr(hlapi, MAP_PRIV_PROTOCOLS[privproto]),
+        )
     else:
-        request_args = [
-            SnmpEngine(),
-            CommunityData(community, mpModel=SNMP_VERSIONS[version]),
-            target,
-            ContextData(),
-        ]
-    get_result = await getCmd(*request_args, ObjectType(ObjectIdentity(baseoid)))
+        auth_data = CommunityData(community, mpModel=SNMP_VERSIONS[version])
+
+    request_args = await async_create_request_cmd_args(hass, auth_data, target, baseoid)
+    get_result = await getCmd(*request_args)
     errindication, _, _, _ = get_result
 
     if errindication and not accept_errors:
@@ -244,9 +232,7 @@ def __init__(self, request_args, baseoid, accept_errors, default_value) -> None:
     async def async_update(self):
         """Get the latest data from the remote SNMP capable host."""
 
-        get_result = await getCmd(
-            *self._request_args, ObjectType(ObjectIdentity(self._baseoid))
-        )
+        get_result = await getCmd(*self._request_args)
         errindication, errstatus, errindex, restable = get_result
 
         if errindication and not self._accept_errors:
diff --git a/homeassistant/components/snmp/switch.py b/homeassistant/components/snmp/switch.py
index a447cdc8e9c5c7..40083ed4213f63 100644
--- a/homeassistant/components/snmp/switch.py
+++ b/homeassistant/components/snmp/switch.py
@@ -8,10 +8,6 @@
 import pysnmp.hlapi.asyncio as hlapi
 from pysnmp.hlapi.asyncio import (
     CommunityData,
-    ContextData,
-    ObjectIdentity,
-    ObjectType,
-    SnmpEngine,
     UdpTransportTarget,
     UsmUserData,
     getCmd,
@@ -67,6 +63,7 @@
     MAP_PRIV_PROTOCOLS,
     SNMP_VERSIONS,
 )
+from .util import RequestArgsType, async_create_request_cmd_args
 
 _LOGGER = logging.getLogger(__name__)
 
@@ -132,40 +129,54 @@ async def async_setup_platform(
     host = config.get(CONF_HOST)
     port = config.get(CONF_PORT)
     community = config.get(CONF_COMMUNITY)
-    baseoid = config.get(CONF_BASEOID)
+    baseoid: str = config[CONF_BASEOID]
     command_oid = config.get(CONF_COMMAND_OID)
     command_payload_on = config.get(CONF_COMMAND_PAYLOAD_ON)
     command_payload_off = config.get(CONF_COMMAND_PAYLOAD_OFF)
-    version = config.get(CONF_VERSION)
+    version: str = config[CONF_VERSION]
     username = config.get(CONF_USERNAME)
     authkey = config.get(CONF_AUTH_KEY)
-    authproto = config.get(CONF_AUTH_PROTOCOL)
+    authproto: str = config[CONF_AUTH_PROTOCOL]
     privkey = config.get(CONF_PRIV_KEY)
-    privproto = config.get(CONF_PRIV_PROTOCOL)
+    privproto: str = config[CONF_PRIV_PROTOCOL]
     payload_on = config.get(CONF_PAYLOAD_ON)
     payload_off = config.get(CONF_PAYLOAD_OFF)
     vartype = config.get(CONF_VARTYPE)
 
+    if version == "3":
+        if not authkey:
+            authproto = "none"
+        if not privkey:
+            privproto = "none"
+
+        auth_data = UsmUserData(
+            username,
+            authKey=authkey or None,
+            privKey=privkey or None,
+            authProtocol=getattr(hlapi, MAP_AUTH_PROTOCOLS[authproto]),
+            privProtocol=getattr(hlapi, MAP_PRIV_PROTOCOLS[privproto]),
+        )
+    else:
+        auth_data = CommunityData(community, mpModel=SNMP_VERSIONS[version])
+
+    request_args = await async_create_request_cmd_args(
+        hass, auth_data, UdpTransportTarget((host, port)), baseoid
+    )
+
     async_add_entities(
         [
             SnmpSwitch(
                 name,
                 host,
                 port,
-                community,
                 baseoid,
                 command_oid,
-                version,
-                username,
-                authkey,
-                authproto,
-                privkey,
-                privproto,
                 payload_on,
                 payload_off,
                 command_payload_on,
                 command_payload_off,
                 vartype,
+                request_args,
             )
         ],
         True,
@@ -180,21 +191,15 @@ def __init__(
         name,
         host,
         port,
-        community,
         baseoid,
         commandoid,
-        version,
-        username,
-        authkey,
-        authproto,
-        privkey,
-        privproto,
         payload_on,
         payload_off,
         command_payload_on,
         command_payload_off,
         vartype,
-    ):
+        request_args,
+    ) -> None:
         """Initialize the switch."""
 
         self._name = name
@@ -206,35 +211,11 @@ def __init__(
         self._command_payload_on = command_payload_on or payload_on
         self._command_payload_off = command_payload_off or payload_off
 
-        self._state = None
+        self._state: bool | None = None
         self._payload_on = payload_on
         self._payload_off = payload_off
-
-        if version == "3":
-            if not authkey:
-                authproto = "none"
-            if not privkey:
-                privproto = "none"
-
-            self._request_args = [
-                SnmpEngine(),
-                UsmUserData(
-                    username,
-                    authKey=authkey or None,
-                    privKey=privkey or None,
-                    authProtocol=getattr(hlapi, MAP_AUTH_PROTOCOLS[authproto]),
-                    privProtocol=getattr(hlapi, MAP_PRIV_PROTOCOLS[privproto]),
-                ),
-                UdpTransportTarget((host, port)),
-                ContextData(),
-            ]
-        else:
-            self._request_args = [
-                SnmpEngine(),
-                CommunityData(community, mpModel=SNMP_VERSIONS[version]),
-                UdpTransportTarget((host, port)),
-                ContextData(),
-            ]
+        self._target = UdpTransportTarget((host, port))
+        self._request_args: RequestArgsType = request_args
 
     async def async_turn_on(self, **kwargs: Any) -> None:
         """Turn on the switch."""
@@ -259,9 +240,7 @@ async def _execute_command(self, command):
 
     async def async_update(self) -> None:
         """Update the state."""
-        get_result = await getCmd(
-            *self._request_args, ObjectType(ObjectIdentity(self._baseoid))
-        )
+        get_result = await getCmd(*self._request_args)
         errindication, errstatus, errindex, restable = get_result
 
         if errindication:
@@ -296,6 +275,4 @@ def is_on(self):
         return self._state
 
     async def _set(self, value):
-        await setCmd(
-            *self._request_args, ObjectType(ObjectIdentity(self._commandoid), value)
-        )
+        await setCmd(*self._request_args, value)
diff --git a/homeassistant/components/snmp/util.py b/homeassistant/components/snmp/util.py
new file mode 100644
index 00000000000000..f9b61a16585755
--- /dev/null
+++ b/homeassistant/components/snmp/util.py
@@ -0,0 +1,65 @@
+"""Support for displaying collected data over SNMP."""
+
+from __future__ import annotations
+
+from functools import cache
+
+from pysnmp.hlapi.asyncio import (
+    CommunityData,
+    ContextData,
+    ObjectIdentity,
+    ObjectType,
+    SnmpEngine,
+    Udp6TransportTarget,
+    UdpTransportTarget,
+    UsmUserData,
+)
+from pysnmp.hlapi.asyncio.cmdgen import vbProcessor
+from pysnmp.smi.builder import MibBuilder
+
+from homeassistant.core import HomeAssistant
+
+type RequestArgsType = tuple[
+    SnmpEngine,
+    UsmUserData | CommunityData,
+    UdpTransportTarget | Udp6TransportTarget,
+    ContextData,
+    ObjectType,
+]
+
+
+@cache
+def snmp_engine() -> SnmpEngine:
+    """Return a cached instance of SnmpEngine."""
+    return SnmpEngine()
+
+
+async def async_create_request_cmd_args(
+    hass: HomeAssistant,
+    auth_data: UsmUserData | CommunityData,
+    target: UdpTransportTarget | Udp6TransportTarget,
+    object_id: str,
+) -> RequestArgsType:
+    """Create request arguments."""
+    return await hass.async_add_executor_job(
+        _create_request_cmd_args, auth_data, target, object_id
+    )
+
+
+def _create_request_cmd_args(
+    auth_data: UsmUserData | CommunityData,
+    target: UdpTransportTarget | Udp6TransportTarget,
+    object_id: str,
+) -> RequestArgsType:
+    """Create request arguments."""
+    engine = snmp_engine()
+    object_identity = ObjectIdentity(object_id)
+    mib_controller = vbProcessor.getMibViewController(engine)
+    # Actually load the MIBs from disk so we do
+    # not do it in the event loop
+    mib_controller.indexMib()
+    builder: MibBuilder = mib_controller.mibBuilder
+    if "PYSNMP-MIB" not in builder.mibSymbols:
+        builder.loadModules()
+    object_identity.resolveWithMib(mib_controller)
+    return (engine, auth_data, target, ContextData(), ObjectType(object_identity))


Code review comments:
diff_hunk: @@ -0,0 +1,65 @@
+"""Support for displaying collected data over SNMP."""
+
+from __future__ import annotations
+
+from functools import cache
+
+from pysnmp.hlapi.asyncio import (
+    CommunityData,
+    ContextData,
+    ObjectIdentity,
+    ObjectType,
+    SnmpEngine,
+    Udp6TransportTarget,
+    UdpTransportTarget,
+    UsmUserData,
+)
+from pysnmp.hlapi.asyncio.cmdgen import vbProcessor
+from pysnmp.smi.builder import MibBuilder
+
+from homeassistant.core import HomeAssistant
+
+type RequestArgsType = tuple[
+    SnmpEngine,
+    UsmUserData | CommunityData,
+    UdpTransportTarget | Udp6TransportTarget,
+    ContextData,
+    ObjectType,
+]
+
+
+@cache
+def snmp_engine() -> SnmpEngine:
+    """Return a cached instance of SnmpEngine."""
+    return SnmpEngine()
+
+
+async def async_create_request_cmd_args(
+    hass: HomeAssistant,
+    auth_data: UsmUserData | CommunityData,
+    target: UdpTransportTarget | Udp6TransportTarget,
+    object_id: str,
+) -> RequestArgsType:
+    """Create request arguments."""
+    return await hass.async_add_executor_job(
+        _create_request_cmd_args, auth_data, target, object_id
+    )
+
+
+def _create_request_cmd_args(
+    auth_data: UsmUserData | CommunityData,
+    target: UdpTransportTarget | Udp6TransportTarget,
+    object_id: str,
+) -> RequestArgsType:
+    """Create request arguments."""
+    engine = snmp_engine()
+    object_identity = ObjectIdentity(object_id)
+    mib_controller = vbProcessor.getMibViewController(engine)
+    # Actually load the MIBs from disk so we do
+    # not do it in the event loop
+    mib_controller.indexMib()
+    builder: MibBuilder = mib_controller.mibBuilder
+    if "PYSNMP-MIB" not in builder.mibSymbols:
+        builder.loadModules()
+    object_identity.resolveWithMib(mib_controller)
path: homeassistant/components/snmp/util.py
text: @author:
Not sure this is needed if the mibs are already loaded in the singleton

diff_hunk: @@ -0,0 +1,65 @@
+"""Support for displaying collected data over SNMP."""
+
+from __future__ import annotations
+
+from functools import cache
+
+from pysnmp.hlapi.asyncio import (
+    CommunityData,
+    ContextData,
+    ObjectIdentity,
+    ObjectType,
+    SnmpEngine,
+    Udp6TransportTarget,
+    UdpTransportTarget,
+    UsmUserData,
+)
+from pysnmp.hlapi.asyncio.cmdgen import vbProcessor
+from pysnmp.smi.builder import MibBuilder
+
+from homeassistant.core import HomeAssistant
+
+type RequestArgsType = tuple[
+    SnmpEngine,
+    UsmUserData | CommunityData,
+    UdpTransportTarget | Udp6TransportTarget,
+    ContextData,
+    ObjectType,
+]
+
+
+@cache
+def snmp_engine() -> SnmpEngine:
+    """Return a cached instance of SnmpEngine."""
+    return SnmpEngine()
+
+
+async def async_create_request_cmd_args(
+    hass: HomeAssistant,
+    auth_data: UsmUserData | CommunityData,
+    target: UdpTransportTarget | Udp6TransportTarget,
+    object_id: str,
+) -> RequestArgsType:
+    """Create request arguments."""
+    return await hass.async_add_executor_job(
+        _create_request_cmd_args, auth_data, target, object_id
+    )
+
+
+def _create_request_cmd_args(
+    auth_data: UsmUserData | CommunityData,
+    target: UdpTransportTarget | Udp6TransportTarget,
+    object_id: str,
+) -> RequestArgsType:
+    """Create request arguments."""
+    engine = snmp_engine()
+    object_identity = ObjectIdentity(object_id)
+    mib_controller = vbProcessor.getMibViewController(engine)
+    # Actually load the MIBs from disk so we do
+    # not do it in the event loop
+    mib_controller.indexMib()
+    builder: MibBuilder = mib_controller.mibBuilder
+    if "PYSNMP-MIB" not in builder.mibSymbols:
path: homeassistant/components/snmp/util.py
text: @author:
I think we can move this check into the singleton