Move imports in snmp component (#27939)

* move imports in snmp component

* fix: move hlapi import top level
This commit is contained in:
Michał Mrozek 2019-10-20 10:06:32 +02:00 committed by Fabian Affolter
parent a5ec5b567e
commit e01562ceea
3 changed files with 25 additions and 24 deletions

View file

@ -2,6 +2,17 @@
from datetime import timedelta
import logging
import pysnmp.hlapi.asyncio as hlapi
from pysnmp.hlapi.asyncio import (
CommunityData,
ContextData,
ObjectIdentity,
ObjectType,
SnmpEngine,
UdpTransportTarget,
UsmUserData,
getCmd,
)
import voluptuous as vol
from homeassistant.components.sensor import PLATFORM_SCHEMA
@ -70,16 +81,6 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
"""Set up the SNMP sensor."""
from pysnmp.hlapi.asyncio import (
getCmd,
CommunityData,
SnmpEngine,
UdpTransportTarget,
ContextData,
ObjectType,
ObjectIdentity,
UsmUserData,
)
name = config.get(CONF_NAME)
host = config.get(CONF_HOST)
@ -101,7 +102,6 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
value_template.hass = hass
if version == "3":
import pysnmp.hlapi.asyncio as hlapi
if not authkey:
authproto = "none"
@ -194,7 +194,6 @@ class SnmpData:
async def async_update(self):
"""Get the latest data from the remote SNMP capable host."""
from pysnmp.hlapi.asyncio import getCmd, ObjectType, ObjectIdentity
errindication, errstatus, errindex, restable = await getCmd(
*self._request_args, ObjectType(ObjectIdentity(self._baseoid))