BroadLink Bestcon SCB1e integration

Hi There,

Could we please get support for the Broadlink Wifi control boxes in hassio?

http://www.mybestcon.com/scb1e.html

It supports high amperage (16A) with power monitoring in a small footprint. These devices could easily fit behind existing wall sockets and turn them into smart switches with power monitoring. All the other ones i have found are too large (Sonoff POW2 )

Please click on Vote for this feature request. (Top left corner when logged in)

I see there’s a new pull request on the python-broadlink component (a requirement for the broadlink hassio component) that includes support for SCB1e and a whole bunch of other broadlink switches/plugs.

Hopefully this could be implemented in the next release.

By the way, the old SC1 is no more available; based on this, the integration of the new Broadlink switches is necessary…

Yes, I had to switch from the SC1 too. MCB1 works and has been integrated to the broadlink python library. It’s not yet in HA but just add one line in the broadlink library and it’s ok.
I’m also using a SCB1E in my HA system and I gave the information from this device to the python-broadlink dev. (very nice and quick to update btw). It works but still lacks the power monitor functions (can do with python code, not imported in HA yet)
MCB1 is better than SC1, way smaller. SCB1E is a little bit larger but adds power monitor.

Where is located the python library in HassIO? I wasn’t able to locate it… (at the first sight).

Can you post the lines you added?

I can’t tell you where, I’m on an ubuntu server with Venv. So the library is in <venv>/homeassistant/lib/python3.8/site-packages/broadlink.
Maybe you can try a “find / -name ‘remote.py’” it’ll list you all integration with a remote device, there are not that many I think (less than device.py or switch.py)

I added in the __init__.py file the lines I needed for my devices, depends on what yours are :

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

Thanks :+1:. Now I have only to figure out where the broadlink integration files have been copied in the HassIO filesystem…

I added the MCB1 in my HA after editing the initt.py file, but after a while the device was no more available? Any idea?

PS: i blocked also the internet connection for the switch, but no luck…

MCB1 works fine here for a couple of weeks (I have 2), just one became unavailable once but it’s in the attic and hasn’t the best WiFi coverage. Off/On and it never went away since.
The 2 SP4 also happen to become unavailable for a few seconds/minutes.

I updated with the latest PR of the library, and I made a few tests with the HA broadlink integration, and I could make the SCB1e work, even with power management.
I’m not able to publish in the repository, I don’t know the HA rules, so I’m giving information here, if it helps someone :

  • Get latest __init__.py and switch.py from the library (this handles a new SP4S device type, with power management)
  • in the HA broadlink library, update the const.py and change SP4B to SP4S :
11c11
<     (SWITCH_DOMAIN, ("MP1", "RM2", "RM4", "SP1", "SP2", "SP4", "SP4S")),
---
>     (SWITCH_DOMAIN, ("MP1", "RM2", "RM4", "SP1", "SP2", "SP4", "SP4B")),

  • in the updater.py file, change also SP4B to SP4S :
35c35
<         "SP4B": BroadlinkSP4UpdateManager,
---
>         "SP4S": BroadlinkSP4UpdateManager,
  • then add the SP4S class in the switch.py :
    Separate the SP4/SP4S in the setup, change :
     elif device.api.type == "SP4S":
         switches = [BroadlinkSP4SSwitch(device)]

to:

    elif device.api.type == "SP4":
        switches = [BroadlinkSP4Switch(device)]

    elif device.api.type == "SP4S":
        switches = [BroadlinkSP4SSwitch(device)]

And then the class SP4S :

class BroadlinkSP4SSwitch(BroadlinkSP1Switch):
    """Representation of a Broadlink SP4S switch."""

    def __init__(self, device, *args, **kwargs):
        """Initialize the switch."""
        super().__init__(device, *args, **kwargs)
        self._state = self._coordinator.data["pwr"]
        try:
            self._load_power = self._coordinator.data["power"]
        except:
            self._load_power = 0

    @property
    def assumed_state(self):
        """Return True if unable to access real state of the switch."""
        return False

    @property
    def current_power_w(self):
        """Return the current power usage in Watt."""
        return self._load_power

    @callback
    def update_data(self):
        """Update data."""
        if self._coordinator.last_update_success:
            self._state = self._coordinator.data["pwr"]
            try:
              self._load_power = self._coordinator.data["power"]
            except:
              self._load_power = 0.01

        self.async_write_ha_state()

In HA, see the SCB1e with new attribute :

current_power_w: 0
friendly_name: Prise LV
device_class: outlet
icon: 'mdi:dishwasher'

The SP4L plug is also getting the curent_power_w attribute even if it doesn’t monitor power. Same as the SC1, using the SP2 class and showing 0.01W.

This is just a workaround and a proof of concept that just works in my environment. I’m sure a much better dev than I am will come with an official upgrade, but if in the meantime it helps someone, then great ! Feel free to re-use, enhance, distribute, test (at your own risks ! :wink: )