Fix GitHub change to resolve conflicts (#16477)

This commit is contained in:
Fabian Affolter 2018-09-07 14:41:31 +02:00 committed by GitHub
parent d0f9d125a7
commit a5715c48a4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -86,8 +86,8 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
}) })
async def async_setup_platform(
def setup_platform(hass, config, add_entities, discovery_info=None): hass, config, async_add_entities, discovery_info=None):
"""Set up the SNMP switch.""" """Set up the SNMP switch."""
name = config.get(CONF_NAME) name = config.get(CONF_NAME)
host = config.get(CONF_HOST) host = config.get(CONF_HOST)
@ -106,21 +106,20 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
payload_on = config.get(CONF_PAYLOAD_ON) payload_on = config.get(CONF_PAYLOAD_ON)
payload_off = config.get(CONF_PAYLOAD_OFF) payload_off = config.get(CONF_PAYLOAD_OFF)
add_entities( async_add_entities(
[SnmpSwitch(name, host, port, community, baseoid, command_oid, version, [SnmpSwitch(
username, authkey, authproto, privkey, privproto, name, host, port, community, baseoid, command_oid, version,
payload_on, payload_off, username, authkey, authproto, privkey, privproto, payload_on,
command_payload_on, command_payload_off)], True) payload_off, command_payload_on, command_payload_off)], True)
class SnmpSwitch(SwitchDevice): class SnmpSwitch(SwitchDevice):
"""Representation of a SNMP switch.""" """Representation of a SNMP switch."""
def __init__(self, name, host, port, community, def __init__(self, name, host, port, community, baseoid, commandoid,
baseoid, commandoid, version, version, username, authkey, authproto, privkey, privproto,
username, authkey, authproto, privkey, privproto, payload_on, payload_off, command_payload_on,
payload_on, payload_off, command_payload_off):
command_payload_on, command_payload_off):
"""Initialize the switch.""" """Initialize the switch."""
from pysnmp.hlapi.asyncio import ( from pysnmp.hlapi.asyncio import (
CommunityData, ContextData, SnmpEngine, CommunityData, ContextData, SnmpEngine,
@ -156,14 +155,14 @@ class SnmpSwitch(SwitchDevice):
privProtocol=getattr(hlapi, MAP_PRIV_PROTOCOLS[privproto]), privProtocol=getattr(hlapi, MAP_PRIV_PROTOCOLS[privproto]),
), ),
UdpTransportTarget((host, port)), UdpTransportTarget((host, port)),
ContextData() ContextData(),
] ]
else: else:
self._request_args = [ self._request_args = [
SnmpEngine(), SnmpEngine(),
CommunityData(community, mpModel=SNMP_VERSIONS[version]), CommunityData(community, mpModel=SNMP_VERSIONS[version]),
UdpTransportTarget((host, port)), UdpTransportTarget((host, port)),
ContextData() ContextData(),
] ]
async def async_turn_on(self, **kwargs): async def async_turn_on(self, **kwargs):
@ -184,9 +183,7 @@ class SnmpSwitch(SwitchDevice):
from pyasn1.type.univ import (Integer) from pyasn1.type.univ import (Integer)
errindication, errstatus, errindex, restable = await getCmd( errindication, errstatus, errindex, restable = await getCmd(
*self._request_args, *self._request_args, ObjectType(ObjectIdentity(self._baseoid)))
ObjectType(ObjectIdentity(self._baseoid))
)
if errindication: if errindication:
_LOGGER.error("SNMP error: %s", errindication) _LOGGER.error("SNMP error: %s", errindication)