Anyone get Broadlink SP4M-US WiFi Smart Plug Working? Locally?

I picked up a cheap Broadlink SP4M-US WiFi smart plug just to try it out.

Has anyone gotten one of these working? Were you able to get local control, or only through the Broadlink cloud?

Reading the documentation for the HA Broadlink integration, it mentions that this model is supported, but talks a lot about IR, not about WiFi. The app that the Broadlink instructions link me to appears to be for a universal IR remote, not a WiFi smart plug.

I’ve got it connecting to my home router OK, but when I try to add it using the HA Broadlink integration, I get a message saying it’s “locked” and I need to use the app to unlock it. I’m not even sure I have the right app. Although I don’t want it to connect to their cloud, I’m OK doing that just to set it up. Then I’ll block the device from getting through the router to the internet.

Does any of this sound possible, or have I just wasted $6 on this experiment?

Looks like there’s something with the latest (4th generation) Broadlink devices that when you add it with app, then it goes into “locked” mode and works only with cloud.

See the broadlink python library github (https://github.com/mjg59/python-broadlink) for full details.
But you could make it work with :

  • reset the plug into noapp mode : press 5s the on/off button, it should blink slow 4 times/led off/blink 4 times etc etc…
  • connect your PC/laptop to the plug AP : broadlink_wifi_device
  • use the python library scripts to set the wifi (after that you’ll be disconnected from the AP) :
broadlink_cli --joinwifi YourSSID YourKey
  • find which IP address has your SP4M
  • add it manually in HA

If the type is known, this should work.

2 Likes

Thanks! I was hoping to avoid having to dig into the python, but now that I have the link, maybe I’ll give it a look.

The app allowed me to turn the “locked” mode off, after which the HA integration worked. What I can’t tell is whether or not it uses the cloud, or if HA communicates locally with it. I may have to do some network traces. I tried using the parental controls on my router to block it from the internet but the router instructions aren’t clear so I may have it backwards and be allowing access instead of blocking it.

The reference material which came with the smart plug shows the 5-second reset to “noapp” mode, and a 10+ second reset to “smart” mode. I’ve been playing with “noapp” but it still uses the app, so I’m not sure what the modes really mean.

My next test will be to disconnect the router from the internet and see if it still works, but I have to wait until no-one else is using it.

HA is using the python-broadlink library, and it probes directly the device, not using cloud.
I have my IOT devices in a separate VLAN/SSID and they can’t access Internet, most of them are not even ever configured through the native app. Broadlink was great for that, now seems there are devices needing internet access, at least during configuration, SP4 is one of those from my recent experience.

The noapp mode starts a WiFi app on the device, and a web server that serves only one page where you can set parameters : wifi SSID, wifi pass, user mail (cloud account) and then Alexa or Google Home can access it. Broadlink app isn’t needed.
The python-broadlink library uses this mode to send WiFi information and that’s it, it can work with HA.

1 Like

Thank you, Mister_Slowhand!!

That explains a lot. Now I understand why they call it “no app.” Direct C2C between their cloud and the Alexa or Google cloud. Not what I want, but it’s a nice solution for anyone who doesn’t want to set up local stuff like HA.

The only testing I’ve been able to do so far suggests that the Broadlink app can still control the device, even though (I think) I have the router set to block any traffic to or from the device. As I said above, I’m using “parental controls” for this (TP-Link router) and the documentation really sucks, so it could be I’m not blocking anything.

I’m not super paranoid about Broadlink getting information about my switch usage. I just want to verify that the system continues to work locally even if my internet connection drops.

Thanks for linking that library it helped me get this switch into HA.

Wanted to share the steps I used to get this working with Ubuntu 20.
In short, you need a laptop/desktop pc with WiFi. I used a Ubuntu VM with a WiFi USB,

sudo apt install python3.8 python3-pip
sudo pip3 install broadlink

Download https://github.com/mjg59/python-broadlink
and cd into the broadlink/cli folder

Join the WiFi Accesspoint generated by the plug on your ubuntu install.
Run the following

./broadlink_cli --joinwifi YourSSID YourKey

^ Before running make sure you CD into the broadlink/cli folder.
Note: If your SSID has spaces put your SSID in ’ '.

It just joined my network, assigned a static IP via DHCP and was able to add it via HA intragrations page.

This Vs Tuya convert is about the same in time/difficulty IMO. Still really happy I got this to work as I got these plugs for like $3-4 on Cyber Monday.

Tuya convert now can be risky as some devices are protected. I’ve tried cheap ‘Action’ plugs that I couldn’t convert. That’s why I stayed with Broadlink.

For reference, if the HA integration still doesn’t work after these steps, then maybe you have a device with an unknown device ID. To make sure, use a little bit of python :

$ python
Python 3.8.6 (default, Sep 25 2020, 09:36:53) 
[GCC 10.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import broadlink as blk
>>> dev=blk.hello("192.168.7.51")
>>> dev.auth()
True
>>> dev.get_state()
{'pwr': 1, 'indicator': 1, 'maxworktime': 0, 'current': 12, 'volt': 235400, 'power': 0, 'totalconsum': 1040, 'overload': 0, 'childlock': 0}
>>> dev
<sp4b: Broadlink SCB1E (0x6113) at 192.168.7.51:80 | 24:df:a7:18:93:24 | SCB1E | Unlocked>

This is a known device (because I pulled an update from the github), so I can get the get_state result. Otherwise, just print out the object “dev” and see if the device type (0x…) is in the library list.
If it ain’t, if you can try and modify the library to find out which class it can work with (SP2, SP4, SP4B…), and have it added in the library.

Just to keep everyone up to date, I think I have successfully tested that blocking the Broadlink cloud works.

The issue was that my crappy TP-Link router’s parental controls are awful. Not only is the UI misleading and the documentation poor, but it doesn’t actually work as documented. All it does is block DNS. Once the connection is established, the device can continue to merrily communicate back to the “mother ship” cloud (and your kids can continue to watch porn or whatever it is you’re trying to “control.”)

But unplugging the Broadlink device after parental controls were in place seems to have blocked it from communicating back to their cloud. I now get “Device is offline” in their app from outside my network, but HA works fine in the network, as does the app.

Of course, I can still control the device from outside my network through HA.

I’m calling this a passing grade on my “works without the cloud” test. It also meets my secondary goal of no coding required. It is necessary to set up an account with the Broadlink cloud and to install the Broadlink Universal Remote app. But you can use a disposable e-mail account, and un-install the app after.

I think I’ll buy a few more of these. Simple, effective and the price is right!

HassBuddy,

I am trying this on my SP4M-US switches and I get no response from the --joinwifi command. I’m using Ubuntu 18.04 on WSL if it makes any difference. I purchased 4 of these switches. Been unable to see only one on the network if I register/unlock via the app.

If the SP4M acts like my SP4L-EU (which could be because they both work with class “sp4b”), they won’t connect unless they have internet access.
So I had to open my IOT network, connect with “–joinwifi”, let the devices work a little bit (several minutes), then close the network again. They work fine as long as HA is working, as it’s connecting to the devices regularly. Otherwise, they reboot and it seems they lose configuration then !!

But, you won’t get any answer from the ‘–joinwifi’ command, you will just get disconnected from the BroadLink_WiFi_Device AP when the device connects to your WiFi network.

Thanks for responding. After many attempts, I was able to get it connected to my wifi using the broadlink app. The IOT network was open to the internet. The app would never complete setup, but the device did connect to wifi, and I could then attach to HA.

Interesting. My SP4M-US didn’t do that, at least this time. I had a power issue with my RPi3B+ (apparently not uncommon) and HA was down for over 24 hours. The SP4M was on the internal network, but unable to connect to the internet, the whole time. HA is now back and able to control the SP4M.

This may not disprove your theory, however. I haven’t confirmed yet that my TP-Link router’s “parental controls” really block the device. I suspect it’s only blocking DNS lookups. The point is, there’s something happening I’m not 100% sure of yet. Would be interested in hearing other folks’ experiences with these devices.

I’m not sure about the “losing configuration” part. It happened when I configured and tested at first, when they weren’t connected to HA, juste tests with the python library. After I unplugged them, when I plugged them back, they were in “noapp configuration” mode again.
Since I integrated them, I haven’t stopped HA for more than a few seconds (restart) and didn’t have power outage. Finger crossed !

But I’m sure they don’t act like other broadlink devices, including the most recent SCB1/MCB1 that don’t need Internet access at all. Depending on the form factor you need, could be a good alternative, even less expensive.

Update: Today I was fooling around resetting my SP4M-US and re-connecting it to my local network. I confirmed that the blocking in my router is working, because the smart plug couldn’t connect after joining my network until I suspended the blocking. So it’s been working without external connectivity. Good!

Resetting the device went well, and when it re-joined my network the HA integration saw and controlled it without issue. I’ll be buying more of these devices. I would still prefer a totally local setup, since I have no idea how much data they’re collecting.

I set up another of these, and documented the steps I used to install it. I put these instructions over in the “Share Your Projects” area:

No matter what I do the second SP4M-US connects to the FastCon system. There must have been some kind of firmware update between the time you connected yours and the time I purchased mine because no matter what order I do this in, and I’ve tried several, the second one hides in the firsts IP.

There must be some work around that would allow us to connect to other SP4M-US switches using just one IP address.

Same here, got the SP4M-EU and no matter what I do with it, not able to integrate it in HA.
Does anybody else managed to get them integrated?

I have added a ticket in Github. Hopefully this gets resolved.