t0mer / broadlinkmanager-docker

Broadlink Manager is a python based project that allows you to contorol your broadlink devices. Discover, Leran and send command in a very easy way
Apache License 2.0
259 stars 56 forks source link

Unable to Learn IR/RF Codes #75

Open sameleff opened 8 months ago

sameleff commented 8 months ago

<< see bottom for additional edits >>

I was unable to get my RM4 Pro device connected to my WiFi network using the desktop Broadlink Manager app (I suspect because my SSID has a space in it); however, using the official Broadlink app worked.

Next, I spun up the Broadlink Manager docker version, and created a devices.json file with my RM4 Pro information. I can see (and successfully ping) my device from the webGUI, but whenever I click "Learn IR/RF Code" I receive an error like the below. Since I'm unsure of my exact device type ID (nor who to find it), I tried every device type from the readme but each behaved the same (status shows as online, successful ping, then the below error).

INFO:     172.18.0.7:57962 - "GET /device/ping?host=192.168.1.49 HTTP/1.1" 200 OK
2023-12-14 19:51:32.274 | INFO     | __main__:learnir:447 - Learning IR Code for device: 192.168.1.49
INFO:     172.18.0.7:41318 - "GET /ir/learn?type=0x61A2&host=192.168.1.49&mac=<redacted> HTTP/1.1" 500 Internal Server Error
ERROR:    Exception in ASGI application
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/dist-packages/uvicorn/protocols/http/h11_impl.py", line 408, in run_asgi
    result = await app(  # type: ignore[func-returns-value]
  File "/usr/local/lib/python3.8/dist-packages/uvicorn/middleware/proxy_headers.py", line 84, in __call__
    return await self.app(scope, receive, send)
  File "/usr/local/lib/python3.8/dist-packages/fastapi/applications.py", line 1106, in __call__
    await super().__call__(scope, receive, send)
  File "/usr/local/lib/python3.8/dist-packages/starlette/applications.py", line 122, in __call__
    await self.middleware_stack(scope, receive, send)
  File "/usr/local/lib/python3.8/dist-packages/starlette/middleware/errors.py", line 184, in __call__
    raise exc
  File "/usr/local/lib/python3.8/dist-packages/starlette/middleware/errors.py", line 162, in __call__
    await self.app(scope, receive, _send)
  File "/usr/local/lib/python3.8/dist-packages/starlette/middleware/cors.py", line 83, in __call__
    await self.app(scope, receive, send)
  File "/usr/local/lib/python3.8/dist-packages/starlette_exporter/middleware.py", line 328, in __call__
    await self.app(scope, receive, wrapped_send)
  File "/usr/local/lib/python3.8/dist-packages/starlette/middleware/exceptions.py", line 79, in __call__
    raise exc
  File "/usr/local/lib/python3.8/dist-packages/starlette/middleware/exceptions.py", line 68, in __call__
    await self.app(scope, receive, sender)
  File "/usr/local/lib/python3.8/dist-packages/fastapi/middleware/asyncexitstack.py", line 20, in __call__
    raise e
  File "/usr/local/lib/python3.8/dist-packages/fastapi/middleware/asyncexitstack.py", line 17, in __call__
    await self.app(scope, receive, send)
  File "/usr/local/lib/python3.8/dist-packages/starlette/routing.py", line 718, in __call__
    await route.handle(scope, receive, send)
  File "/usr/local/lib/python3.8/dist-packages/starlette/routing.py", line 276, in handle
    await self.app(scope, receive, send)
  File "/usr/local/lib/python3.8/dist-packages/starlette/routing.py", line 66, in app
    response = await func(request)
  File "/usr/local/lib/python3.8/dist-packages/fastapi/routing.py", line 274, in app
    raw_response = await run_endpoint_function(
  File "/usr/local/lib/python3.8/dist-packages/fastapi/routing.py", line 193, in run_endpoint_function
    return await run_in_threadpool(dependant.call, **values)
  File "/usr/local/lib/python3.8/dist-packages/starlette/concurrency.py", line 41, in run_in_threadpool
    return await anyio.to_thread.run_sync(func, *args)
  File "/usr/local/lib/python3.8/dist-packages/anyio/to_thread.py", line 33, in run_sync
    return await get_asynclib().run_sync_in_worker_thread(
  File "/usr/local/lib/python3.8/dist-packages/anyio/_backends/_asyncio.py", line 877, in run_sync_in_worker_thread
    return await future
  File "/usr/local/lib/python3.8/dist-packages/anyio/_backends/_asyncio.py", line 807, in run
    result = context.run(func, *args)
  File "broadlinkmanager.py", line 448, in learnir
    dev = initDevice(type, host, mac)
  File "broadlinkmanager.py", line 376, in initDevice
    _mac = bytearray.fromhex(mac)
ValueError: non-hexadecimal number found in fromhex() arg at position 2

Edit 1: I did confirm that I was able to use the Broadlink app to learn (and send) IR codes. Ideally, I'd like to completely eliminate my dependence on the app and exclusively use Broadlink Manager to both provision and configure my device.

Edit 2: I was able to connect my device to my WiFi network using the python broadlink module. I have confirmed via the output from python that my device is of type 0x5213. However, when I add this to my devices.json within Broadlink Manager, I still receive the same errors when attempting to learn IR/RF codes. I was also able to successfully enter IR learning mode and learn a code using the python tool, as described here. This issue therefore indeed appears to stem from Broadlink Manager and not from my device or my configs.