Skip to content

Commit

Permalink
auto detect zzh usb port
Browse files Browse the repository at this point in the history
  • Loading branch information
sanyatuning committed May 8, 2020
1 parent ba2e321 commit 3000303
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion zigpy_cc/uart.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@
MinMessageLength = 5
MaxDataSize = 250

''''
0451: Texas Instruments
1a86:7523 QinHeng Electronics HL-340 USB-Serial adapter
used in zzh - https://electrolama.com/projects/zig-a-zig-ah/
'''
usb_regexp = "0451:|1a86:7523"

class Parser:
def __init__(self) -> None:
Expand Down Expand Up @@ -161,7 +167,7 @@ async def connect(config: Dict[str, Any], api, loop=None) -> Gateway:

port, baudrate = config[CONF_DEVICE_PATH], config[CONF_DEVICE_BAUDRATE]
if port == "auto":
devices = list(serial.tools.list_ports.grep("0451:"))
devices = list(serial.tools.list_ports.grep(usb_regexp))
if devices:
port = devices[0].device
LOGGER.info("%s found at %s", devices[0].product, port)
Expand Down

0 comments on commit 3000303

Please sign in to comment.