mirror of
https://github.com/mjg59/python-broadlink.git
synced 2024-11-22 07:00:12 +01:00
Improve annotations
This commit is contained in:
parent
08c020e597
commit
487a13d895
@ -3,7 +3,7 @@
|
|||||||
import socket
|
import socket
|
||||||
import time
|
import time
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from typing import List, Union, Tuple
|
from typing import Dict, List, Union, Tuple, Type
|
||||||
|
|
||||||
from .alarm import S1C
|
from .alarm import S1C
|
||||||
from .cover import dooya
|
from .cover import dooya
|
||||||
@ -17,7 +17,7 @@ from .switch import bg1, mp1, sp1, sp2
|
|||||||
from .helpers import calculate_crc16, get_local_ip
|
from .helpers import calculate_crc16, get_local_ip
|
||||||
|
|
||||||
|
|
||||||
def get_devices() -> dict:
|
def get_devices() -> Dict[int, Tuple[Type[device], str, str]]:
|
||||||
"""Return all supported devices."""
|
"""Return all supported devices."""
|
||||||
return {
|
return {
|
||||||
0x0000: (sp1, "SP1", "Broadlink"),
|
0x0000: (sp1, "SP1", "Broadlink"),
|
||||||
@ -90,7 +90,7 @@ def gendevice(
|
|||||||
mac: Union[bytes, str],
|
mac: Union[bytes, str],
|
||||||
name: str = None,
|
name: str = None,
|
||||||
is_locked: bool = None,
|
is_locked: bool = None,
|
||||||
):
|
) -> device:
|
||||||
"""Generate a device."""
|
"""Generate a device."""
|
||||||
try:
|
try:
|
||||||
dev_class, model, manufacturer = get_devices()[dev_type]
|
dev_class, model, manufacturer = get_devices()[dev_type]
|
||||||
@ -114,7 +114,7 @@ def discover(
|
|||||||
local_ip_address: str = None,
|
local_ip_address: str = None,
|
||||||
discover_ip_address: str = '255.255.255.255',
|
discover_ip_address: str = '255.255.255.255',
|
||||||
discover_ip_port: int = 80,
|
discover_ip_port: int = 80,
|
||||||
) -> list:
|
) -> List[device]:
|
||||||
"""Discover devices connected to the local network."""
|
"""Discover devices connected to the local network."""
|
||||||
local_ip_address = local_ip_address or get_local_ip()
|
local_ip_address = local_ip_address or get_local_ip()
|
||||||
address = local_ip_address.split('.')
|
address = local_ip_address.split('.')
|
||||||
|
@ -19,7 +19,7 @@ class hysen(device):
|
|||||||
# New behaviour: raises a ValueError if the device response indicates an error or CRC check fails
|
# New behaviour: raises a ValueError if the device response indicates an error or CRC check fails
|
||||||
# The function prepends length (2 bytes) and appends CRC
|
# The function prepends length (2 bytes) and appends CRC
|
||||||
|
|
||||||
def send_request(self, input_payload: bytes) -> bytes:
|
def send_request(self, input_payload: bytearray) -> bytes:
|
||||||
"""Send a request to the device."""
|
"""Send a request to the device."""
|
||||||
crc = calculate_crc16(bytes(input_payload))
|
crc = calculate_crc16(bytes(input_payload))
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user