SNMP switch fix integer support (#28425)
This commit is contained in:
parent
07337badcd
commit
c7d72f55e9
1 changed files with 14 additions and 3 deletions
|
@ -1,6 +1,8 @@
|
||||||
"""Support for SNMP enabled switch."""
|
"""Support for SNMP enabled switch."""
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
from pyasn1.type.univ import Integer
|
||||||
|
|
||||||
import pysnmp.hlapi.asyncio as hlapi
|
import pysnmp.hlapi.asyncio as hlapi
|
||||||
from pysnmp.hlapi.asyncio import (
|
from pysnmp.hlapi.asyncio import (
|
||||||
CommunityData,
|
CommunityData,
|
||||||
|
@ -190,15 +192,20 @@ class SnmpSwitch(SwitchDevice):
|
||||||
|
|
||||||
async def async_turn_on(self, **kwargs):
|
async def async_turn_on(self, **kwargs):
|
||||||
"""Turn on the switch."""
|
"""Turn on the switch."""
|
||||||
|
if self._command_payload_on.isdigit():
|
||||||
|
await self._set(Integer(self._command_payload_on))
|
||||||
|
else:
|
||||||
await self._set(self._command_payload_on)
|
await self._set(self._command_payload_on)
|
||||||
|
|
||||||
async def async_turn_off(self, **kwargs):
|
async def async_turn_off(self, **kwargs):
|
||||||
"""Turn off the switch."""
|
"""Turn off the switch."""
|
||||||
|
if self._command_payload_on.isdigit():
|
||||||
|
await self._set(Integer(self._command_payload_off))
|
||||||
|
else:
|
||||||
await self._set(self._command_payload_off)
|
await self._set(self._command_payload_off)
|
||||||
|
|
||||||
async def async_update(self):
|
async def async_update(self):
|
||||||
"""Update the state."""
|
"""Update the state."""
|
||||||
|
|
||||||
errindication, errstatus, errindex, restable = await getCmd(
|
errindication, errstatus, errindex, restable = await getCmd(
|
||||||
*self._request_args, ObjectType(ObjectIdentity(self._baseoid))
|
*self._request_args, ObjectType(ObjectIdentity(self._baseoid))
|
||||||
)
|
)
|
||||||
|
@ -215,8 +222,12 @@ class SnmpSwitch(SwitchDevice):
|
||||||
for resrow in restable:
|
for resrow in restable:
|
||||||
if resrow[-1] == self._payload_on:
|
if resrow[-1] == self._payload_on:
|
||||||
self._state = True
|
self._state = True
|
||||||
|
elif resrow[-1] == Integer(self._payload_on):
|
||||||
|
self._state = True
|
||||||
elif resrow[-1] == self._payload_off:
|
elif resrow[-1] == self._payload_off:
|
||||||
self._state = False
|
self._state = False
|
||||||
|
elif resrow[-1] == Integer(self._payload_off):
|
||||||
|
self._state = False
|
||||||
else:
|
else:
|
||||||
self._state = None
|
self._state = None
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue