Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 4 additions & 9 deletions homeassistant/components/snmp/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,20 +186,15 @@ def __init__(

async def async_turn_on(self, **kwargs):
"""Turn on the switch."""
from pyasn1.type.univ import Integer

await self._set(Integer(self._command_payload_on))
await self._set(self._command_payload_on)

async def async_turn_off(self, **kwargs):
"""Turn off the switch."""
from pyasn1.type.univ import Integer

await self._set(Integer(self._command_payload_off))
await self._set(self._command_payload_off)

async def async_update(self):
"""Update the state."""
from pysnmp.hlapi.asyncio import getCmd, ObjectType, ObjectIdentity
from pyasn1.type.univ import Integer

errindication, errstatus, errindex, restable = await getCmd(
*self._request_args, ObjectType(ObjectIdentity(self._baseoid))
Expand All @@ -215,9 +210,9 @@ async def async_update(self):
)
else:
for resrow in restable:
if resrow[-1] == Integer(self._payload_on):
if resrow[-1] == self._payload_on:
self._state = True
elif resrow[-1] == Integer(self._payload_off):
elif resrow[-1] == self._payload_off:
self._state = False
else:
self._state = None
Expand Down