Use different version of Broadlink library

I want to get some unsupported bulbs working in HA. The Broadlink integration in HA uses the python-broadlink library, I’ve created a pull request for this library here https://github.com/mjg59/python-broadlink/pull/766 to add the ID for BG Home/Luceco bulbs. This works great and I can control the bulbs from the python interpreter.

I’ve tried adding the modified ‘broadlink’ folder from this repo to the /config/custom_components/broadlink added a manifest.json with {"version": "0.0.0"} followed by a restart, but the Broadlink integration still gives “Device not supported”. The log gives the usual:

ERROR (MainThread) [homeassistant.components.broadlink.config_flow] Unsupported device: 0x606d. If it worked before, please open an issue at https://github.com/home-assistant/core/issues

If I fire up the terminal in HA and do the following:

cd /config/custom_components
pip install cryptography
python3.11
>>> import broadlink
>>> broadlink.hello('192.168.0.56')
broadlink.light.lb1(('192.168.0.56', 80), mac=b'\xec\x0b\xae\x82\x16\xeb', devtype=24685, timeout=10, name='Smart Bulb', model='SLA2?RGB9W81', manufacturer='Luceco/BG Electrical', is_locked=False)

So I know the code is working and correctly identifying my bulb as an unlocked lb1 type light.

Q:How do I get HA to use my version of the broadcom library instead of the unmodified one?

I’m running Home Assistant 2023.9.2 / Supervisor 2023.09.2 / Operating System 10.5 / Frontend 20230911.0 - latest on a Raspberry PI4 2GB built using the Raspberry PI4 Imager.

1 Like

With Home Assistant OS there’s not much you can do afaik. I had the same issue before and got this response by the upstream dev: Broadlink rm4 tv mate not supported · Issue #66547 · home-assistant/core · GitHub
Had to wait two or three months until the package got updated in HA.

I’ve got this working! The mistake I was making was adding the python-broadlink library to custom_components and not a ‘custom component’ :man_facepalming:.

  • Add the files for the HA Core Broadlink component in config\custom_components\broadlink.

  • Put the code for my python-broadlink library in config\custom_components\broadlink\broadlink.

  • To make sure the right code gets loaded replace the line:
    import broadlink as blk
    with:
    from . import broadlink as blk
    in the files config_flow.py, device.py and heartbeat.py

  • In manifest.json remove the line:
    "requirements": ["broadlink==0.18.3"]
    and add
    "version": "0.0.0"
    in its place.

A quick “Restart Home Assistant” and bingo. As long as the lights are powered, connected to your network and not locked they should be discovered by HA.