Broadlink integration for SP4

Can you test using the python code ? This is what I get for my SP4L-EU.

$ python
>>> import broadlink as blk
>>> d = blk.hello("192.168.7.26")
>>> d
<sp4b: Broadlink SP4L-EU (0x618b) at 192.168.7.26:80 | a0:43:b0:00:2f:d0 | 24971 | Unlocked>

The 0x618b code is the device profile, that must be known in the library. It may be not, that’s why it’s not supported. Seems Broadlink uses lots of different types for almost the same device !

I’m not able to do this using the broadlink library in python.

I’m surprised that broadlink devices have so many different types, and they appear to have different behavior !
I guess your SP4 is sp4 type in the python library, while mine works with sp4b type ! With sp4b type, I can turn on/off the nightlight. Seems like you can’t with sp4 type. So weird !

I’m also failing with a SP4L-EU Smartplug.

Is there anything I can do. They work via the broadlink app but the integration reports “device not supported”.

Unsupported device: 0x618b. If it worked before, please open an issue at https://github.com/home-assistant/core/issues

Try and check the __init__.py file from the broadlink library (not the HA component (*)), there’s a list of supported devices. See if the 0x618b is in there. If it ain’t you can add it, this is what I have in mine :

    0x6113: (sp4s, "SCB1E", "Broadlink"),
    0x618b: (sp4s, "SP4L-EU", "Broadlink"),
    0xa56a: (sp4, "MCB1", "Broadlink"),

This should be enough for SP4L support, as it hasn’t power sensor.
If not, you can look here for the full upgrade. Newest Broadlink devices are not (yes) implemented in HA.

(*) Location of components depend on your installation, can’t say for yours.
As an example, on my HA in a virtualenv, Ubuntu server, the HA installation root is in /usr/homeassistant,
so the broadlink library is in /usr/homeassistant/lib/python3.8/site-packages/broadlink.
And HA broadlink component is in /usr/homeassistant/lib/python3.8/site-packages/homeassistant/components/broadlink

thnx for pointing me to this direction. So far I can’t find this file on my system.
Is this file always on a HA installation, even before the Broadkink integration is installed/configured?
I only have two of these smart-plugs so the normal first steps already fail.

What is your installation ? hass.io, virtualenv, docker ?
See the paths I have on my system, it should be the same logic everywhere. I’m only aware of the virtualenv which is the install I use, but if you describe your need, probably someone more aware will be able to help.

I’m using default hass.io on a rpi4.

The folder structure confuses me. If I connect using SSH or SMB plugins it seems I’m in a restricted part of the system. When using visual studio code I can browse “deeper” in the system but still can’t find any folder where site-packages are located.

I’m even questioning if the broadlink files are even there. Are they always as part of the core installation? Or only after installation/configuration of the add-on?

Edit:
I found out using Visual Studio Code there is an option to find a file. (Go > go to file)
Sadly nothing found with broadlink. I did found a lot of other init.py file though.
So I believe the files are not on my system at all because I can’t configure at least 1 working broadlink device first. Any idea how to solve this? Could I copy these files manually?

You should have a least the HA component broadlink. Might be that it only gets the broadlink library first time a device is created. But since you already tried, it should be there, otherwise how could the HA component tell you that it doesn’t know your device type ? They are in the broadlink library, (init.py lists the supported types) not in the HA component !

As homeassistant user, you can search if the broadlink library is there

homeassistant@services:~$ pip list | grep broad
broadlink               0.16.0

You can install the library with

pip install broadlink[=='0.16.0']

The part between [] is optional as 16 is the latest version.

Ofcourse, you make an excellent point! It must be somewhere otherwise it could not throw this error , stupid me…:roll_eyes:

After some troubleshooting a was able to confirm 0.16.0 is installed.

  • Login via SSH & web Terminal
  • docker exec -it homeassistant /bin/bash
  • pip list | grep broad
    result > broadlink 0.16.0

Still no clue were those files are…

After checking Github i also confirm that this version does NOT contain the line
0x618b: (sp4s, “SP4L-EU”, “Broadlink”),

When I check the master branch it DOES contain this line.
However it seems this code is not “released” as a “version” yet. (I’m all new to this…).
Is it also possible to install this master branch in stead of a stable version?

It works! Thank a lot for you support @Mister_Slowhand

pip install broadlink[=='0.16.0']

I’m not exactly sure if that command did the trick.
I also found another command that I used.

docker exec -it homeassistant /bin/bash
pip3 install git+https://github.com/felipediel/python-broadlink.git --force-reinstall --no-deps

But at least after a reboot it is now working and I can add these Smart plugs. :slight_smile: :slight_smile:

The only downside is that the build-in light is not available. That’s maybe because this model is referenced to another model in the code that does not have a light? It not a big deal for now.

1 Like

Thanks for this. Helped me finally get my BG Electrical AHC/U-01 integrated into HA!

Latest updates have not yet been added to the library. I don’t know why.
Neither has the HA component.

The command line you entered upgraded the library to the dev one, including your device. I installed 0.16 and manually modified files as needed.
Nightlight doesn’t work in HA, but the command line tool works (broadlink_cli in git). I tried to create a shell script to integrate but didn’t pursue as in fact I don’t need this light (and i’m kinda lazy) :wink:

Home Assistant OS 5.12
supervisor-2021.03.4
core-2021.3.4
SP4L-EU from BoradLink android app:
firmware v57061
SDK2.16.8 Plug-in ver. 1.5.6
Lock device OFF

I see in my files:

# cat /mnt/data/docker/overlay2/534611ac6893a4194850a643d3f8b0f8c1ad71b3e955f4a1f32e662263071684/diff/usr/local/lib/python3.8/site-packages/broadlink/__init__.py|grep SP4L-EU
    0x7579: (sp4, "SP4L-EU", "Broadlink"),
    0x618B: (sp4b, "SP4L-EU", "Broadlink"),

and also did Frank_R tricks and still got “Device not supported”.
Any other cloes, what to check/try?
Maybe I should make some change in Smart Plug before integration w HA?

2 Likes

So as you might all might be aware of the integration for the SP4L devices has been added to HA recently. The interesting thing I realized with my SP4L-EU’s is that they seemed to ‘merge’ into a single IP, making it impossible to control any of the other plugs, except the ‘master’ device which is directly connected to the appointed SSID.

I pointed this out earlier in this GitHub thread as well.

Today I briefly searched for the full manual of this device, and indeed it seems there is support for master/slave configuration over 802.11. Broadlink calls this protocol “FasCon” (page 2 of manual).

I’d either like to be able to switch this master/client config off, or otherwise make the HA Broadlink integration aware of multiple nested devices. According to the manual (page 31-32) sub/slave/client devices should be listable in the broadlink app on the master device, but I seem to be unable to obtain this info.

Has anyone come across the same phenomenon and found a way to deal with it?
PS: I don’t count setting up multiple SSIDs as a viable and clean solution ;).

Issues about this kind of thing are best handled in python-broadlink from my experience.

I have the same problem! But I didn’t find any secondary device in the Broadlink App.

Yeah, I have the same issue. I tried to get these devices working before and was hoping the new updated integration would work but no luck. The master device is now detected automatically (nice!) but a second “slave” device is not… Using the Broadlink app I can use them both, using the app device info I can see they both use the same IP but have a different MAC. In my Unifi network I only see the master IP.

The HA broadlink integration only seems to recognize the master device. Is there any manual tuning possible here? Any solution yet?

Hi there i have a broadlink sp4l and Im not able to add it to home assistant and get 1 error device not supported!

image

A bit late to the party, but I only recently setup HA to link my smartdevices to.

I came across the same issue with 2 x SP4 plugs. After a lot of investigation I concluded it was Broadlink’s cloud service whereby when registering a subsequent device on their service, the assignes IP to the 2nd (newer) device is then updated on the first device and in effect as far as the LAN is concerned, there are two devices with the same IP and as a result, only one plug would show in HA. One assumes that their cloud integration also uses their MAC addresses to control the units as the units worked fine otherwise. Just not in HA.

To prove this I did two things:

  1. registered the plugs but in reverse sequence. … the plugs reversed their appearance (or not ) in HA. Both registered through the Android app.
  2. On a different smart device (iPad) I used a different email address which I also had on broadlink, and a registered the 2nd device to a different email and in this instance both plugs retained their DHCP IP addresses and appeared fine in HA.

I emailed Broadlink the issue but they haven’t acknowledged the issue that I reported to them (including all the steps I took when registering two devices with the same email address).

On a different note, these plugs have a Night Time LED but I can’t see them in the integration in HA. There are many other entities such as power, voltage etc, but no LED Lamp. Has anyone got the LED to show on the SP4 plug in HA?