Skip to content

Commit

Permalink
Tweak (un)bypass input
Browse files Browse the repository at this point in the history
  • Loading branch information
rrooggiieerr committed Jun 20, 2024
1 parent ac944e4 commit 9419c50
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions unii/unii.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,11 @@ def _forward_to_event_occurred_callbacks(
except Exception as ex:
logger.error("Exception in Event Occurred Callback: %s", ex)

async def bypass_input(self, number: int, usercode: str) -> bool:
async def bypass_input(self, number: int, user_code: str) -> bool:
"""Bypass an input."""
raise NotImplementedError

async def unbypass_input(self, number: int, usercode: str) -> bool:
async def unbypass_input(self, number: int, user_code: str) -> bool:
"""Unypass an input."""
raise NotImplementedError

Expand Down Expand Up @@ -559,29 +559,31 @@ async def _poll_alive_coroutine(self):
self._poll_alive_task = None
logger.debug("Poll Alive coroutine stopped")

async def bypass_input(self, number: int, usercode: str) -> bool:
async def bypass_input(self, number: int, user_code: str) -> bool:
response, data = await self._send_receive(
UNiiCommand.REQUEST_TO_BYPASS_AN_INPUT,
UNiiBypassUnbypassZoneInput(UNiiBypassMode.USER_CODE, usercode, number),
UNiiBypassUnbypassZoneInput(UNiiBypassMode.USER_CODE, user_code, number),
UNiiCommand.RESPONSE_REQUEST_TO_BYPASS_AN_INPUT,
)
if (
response == UNiiCommand.RESPONSE_REQUEST_TO_BYPASS_AN_INPUT
and data.number == number
and data.result == UNiiBypassZoneInputResult.SUCCESSFUL
):
return True

logger.error("Failed to bypass input %i, reason: %s", number, data.result)
return False

async def unbypass_input(self, number: int, usercode: str) -> bool:
async def unbypass_input(self, number: int, user_code: str) -> bool:
response, data = await self._send_receive(
UNiiCommand.REQUEST_TO_UNBYPASS_AN_INPUT,
UNiiBypassUnbypassZoneInput(UNiiBypassMode.USER_CODE, usercode, number),
UNiiBypassUnbypassZoneInput(UNiiBypassMode.USER_CODE, user_code, number),
UNiiCommand.RESPONSE_REQUEST_TO_UNBYPASS_AN_INPUT,
)
if (
response == UNiiCommand.RESPONSE_REQUEST_TO_UNBYPASS_AN_INPUT
and data.number == number
and data.result == UNiiUnbypassZoneInputResult.SUCCESSFUL
):
return True
Expand Down

0 comments on commit 9419c50

Please sign in to comment.