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 ! )