|
@@ -42,7 +42,20 @@ def _encode_message(message: int) -> bytes:
|
|
|
|
|
|
class RemoteControl:
|
|
|
def __init__(self, address: int) -> None:
|
|
|
- assert 0 <= address < 2 ** _ADDRESS_LENGTH_BITS, address
|
|
|
+ if not isinstance(address, int):
|
|
|
+ raise ValueError(
|
|
|
+ "expected {}-bit unsigned integer as address, got {!r}".format(
|
|
|
+ _ADDRESS_LENGTH_BITS, address
|
|
|
+ )
|
|
|
+ )
|
|
|
+ if address < 0:
|
|
|
+ raise ValueError("address must not be negative (got {!r})".format(address))
|
|
|
+ if address >= 2 ** _ADDRESS_LENGTH_BITS:
|
|
|
+ raise ValueError(
|
|
|
+ "address must not exceed {} ({}-bit unsigned integer), got {!r}".format(
|
|
|
+ 2 ** _ADDRESS_LENGTH_BITS, _ADDRESS_LENGTH_BITS, address
|
|
|
+ )
|
|
|
+ )
|
|
|
self._address = address
|
|
|
|
|
|
def _send_command(self, command: int, button_index: int) -> None:
|