Broadlink integration for SP4

The latest version of python-broadlink supports SP4 plugs. Is this going to be added to Home Assistant? The requirements install the latest version, so does the integration’s source code support it? Just want to know before I buy https://www.amazon.com/dp/B08732M6TG.

I know, it’s ugly, and I won’t do it again, but I really want to find this out. The plug has arrived, and I don’t know the best way to do this.

I’ve seen that SP4 is now available with v0.118. So your’s should be working now.

I’m wondering if, along with SP4 support, the MCB1 (which looks like the SC1 replacement) is supported too ? The SC1 could be configured as a SP2 so maybe… I need some of these, I’d rather have the smallest, easy to hide MCB1 than a SP4.

Ask over at the python-broadlink pip library’s github page.

Received SP4L-EU today and integration doesn’t work.
When I try the integration, I get a “device not supported”.

Device is added to my network, in another vlan from the one where HA server sits. But all other broadlink devices work fine that way.

With the python code, I can get that :


dev=blk.hello("192.168.7.26")
dev
<device: None None (0x618b) at 192.168.7.26:80 | a0:43:b0:00:2f:d0 | 24971 | Unlocked>
dev.auth()
True
dev.is_locked
False

Ok, so I added the 0x618b device type in the broadlink libray as a SP4L-EU :

0x618b: (sp4, "SP4L-EU", "Broadlink"),
I now have integration working but device doesn’t appear, in the journal I get an ‘abnormal answer’ error.

Is there anything I did wrong ?

Edit : I have 2 of those, only tested one, and I also have MCB and SCB to test !

Raise an issue over in python-broadlink, are you sure it’s an SP4? The app will say what type it really is.

I’m pretty sure it’s a SP4L-EU, that what I ordered, the seller seems legit (from Ali but still), I got the plug in the broadlink retail box, it says sp4l-eu on the plug itself (serial number in SP95Gxxx).
I’ve documented my experimentations on the github, but for these, I found out it works better with SP4B profile. Maybe it works fine, but I can’t test as it keeps on disconnecting from my network when it hasn’t web access, and return to the NoAPP/local AP mode. Even if I didn’t configure the cloud !

As they seem to act as a SP4M-US version, is there anything different for those plugs to do ?

They did make a PR to send a packet that prevents it from rebooting randomly without the cloud.

In the github thread, Ive had the answer that it’s normal and made me realize HA does this “keep alive” because it checks the status often. 12 hours now and both SP4 are still online ! :crossed_fingers:

I’ll test SCB1E and MCB further when I’ll have more time this week-end to plug them and check the power and voltage values for SCB, hopping to get that in HA.

On the SP4 integration, is the nightlight available in HA ? (it works with broadlink_cli with my SP4M-like SP4L-EU, so worst case I can make a shell script if I want them)

I don’t believe it is, but it could vary by device type. I have a SP4 myself and wasn’t able to even turn on the night light, and it wasn’t in the Broadlink app either.

I’ve just bought some SP4L-UK units and HA is saying “device not supported” also. Is that because it’s the UK unit and not the EU one?

Can you turn it on/off manually ? (double click the button)

Otherwise, with broadlink_cli, you can :
broadlink_cli --type 0x??? --host 192.168.X.Y --mac 1234567890 --checknl
That shows the nightlight status, you have turnnlon/off too.

Then you can create a shell command in HA for on/off and run it in your automation.
Maybe you can even derive a light from this, with the template light. I took a look at it, seems lots of trouble for my use…

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?