Add support for Broadlink SP4 series and the latest SP mini 3 devices (#41522)
* Add support for Broadlink SP4 series * Bump python-broadlink to 0.16 * Fix stale docstringpull/43019/head
parent
30e0d14499
commit
e5fe0c40ec
|
@ -8,7 +8,7 @@ DOMAIN = "broadlink"
|
|||
DOMAINS_AND_TYPES = (
|
||||
(REMOTE_DOMAIN, ("RM2", "RM4")),
|
||||
(SENSOR_DOMAIN, ("A1", "RM2", "RM4")),
|
||||
(SWITCH_DOMAIN, ("MP1", "RM2", "RM4", "SP1", "SP2")),
|
||||
(SWITCH_DOMAIN, ("MP1", "RM2", "RM4", "SP1", "SP2", "SP4", "SP4B")),
|
||||
)
|
||||
|
||||
DEFAULT_PORT = 80
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
"domain": "broadlink",
|
||||
"name": "Broadlink",
|
||||
"documentation": "https://www.home-assistant.io/integrations/broadlink",
|
||||
"requirements": ["broadlink==0.15.0"],
|
||||
"requirements": ["broadlink==0.16.0"],
|
||||
"codeowners": ["@danielhiversen", "@felipediel"],
|
||||
"config_flow": true
|
||||
}
|
||||
|
|
|
@ -121,6 +121,9 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
|
|||
elif device.api.type == "SP2":
|
||||
switches = [BroadlinkSP2Switch(device)]
|
||||
|
||||
elif device.api.type in {"SP4", "SP4B"}:
|
||||
switches = [BroadlinkSP4Switch(device)]
|
||||
|
||||
elif device.api.type == "MP1":
|
||||
switches = [BroadlinkMP1Slot(device, slot) for slot in range(1, 5)]
|
||||
|
||||
|
@ -294,6 +297,27 @@ class BroadlinkSP2Switch(BroadlinkSP1Switch):
|
|||
self.async_write_ha_state()
|
||||
|
||||
|
||||
class BroadlinkSP4Switch(BroadlinkSP1Switch):
|
||||
"""Representation of a Broadlink SP4 switch."""
|
||||
|
||||
def __init__(self, device, *args, **kwargs):
|
||||
"""Initialize the switch."""
|
||||
super().__init__(device, *args, **kwargs)
|
||||
self._state = self._coordinator.data["pwr"]
|
||||
|
||||
@property
|
||||
def assumed_state(self):
|
||||
"""Return True if unable to access real state of the switch."""
|
||||
return False
|
||||
|
||||
@callback
|
||||
def update_data(self):
|
||||
"""Update data."""
|
||||
if self._coordinator.last_update_success:
|
||||
self._state = self._coordinator.data["pwr"]
|
||||
self.async_write_ha_state()
|
||||
|
||||
|
||||
class BroadlinkMP1Slot(BroadlinkSwitch):
|
||||
"""Representation of a Broadlink MP1 slot."""
|
||||
|
||||
|
|
|
@ -31,6 +31,8 @@ def get_update_manager(device):
|
|||
"RM4": BroadlinkRMUpdateManager,
|
||||
"SP1": BroadlinkSP1UpdateManager,
|
||||
"SP2": BroadlinkSP2UpdateManager,
|
||||
"SP4": BroadlinkSP4UpdateManager,
|
||||
"SP4B": BroadlinkSP4UpdateManager,
|
||||
}
|
||||
return update_managers[device.api.type](device)
|
||||
|
||||
|
@ -153,3 +155,11 @@ class BroadlinkSP2UpdateManager(BroadlinkUpdateManager):
|
|||
except (CommandNotSupportedError, StorageError):
|
||||
data["load_power"] = None
|
||||
return data
|
||||
|
||||
|
||||
class BroadlinkSP4UpdateManager(BroadlinkUpdateManager):
|
||||
"""Manages updates for Broadlink SP4 devices."""
|
||||
|
||||
async def async_fetch_data(self):
|
||||
"""Fetch data from the device."""
|
||||
return await self.device.async_request(self.device.api.get_state)
|
||||
|
|
|
@ -380,7 +380,7 @@ boto3==1.9.252
|
|||
bravia-tv==1.0.6
|
||||
|
||||
# homeassistant.components.broadlink
|
||||
broadlink==0.15.0
|
||||
broadlink==0.16.0
|
||||
|
||||
# homeassistant.components.brother
|
||||
brother==0.1.18
|
||||
|
|
|
@ -204,7 +204,7 @@ bond-api==0.1.8
|
|||
bravia-tv==1.0.6
|
||||
|
||||
# homeassistant.components.broadlink
|
||||
broadlink==0.15.0
|
||||
broadlink==0.16.0
|
||||
|
||||
# homeassistant.components.brother
|
||||
brother==0.1.18
|
||||
|
|
Loading…
Reference in New Issue