From 34245a6b3d2c0711665174b732d208dee846b88f Mon Sep 17 00:00:00 2001 From: Matija Kovacic Date: Mon, 3 Apr 2023 13:56:40 +0200 Subject: [PATCH] Add support for Supla garage doors (#90593) * Adding support for additional Supla channel types Newly supported channel types are - CONTROLLINGTHEGARAGEDOOR, DIMMER, RGBLIGHTING. * Remove light platform additions * Remove light devices * Update homeassistant/components/supla/cover.py Co-authored-by: epenet <6771947+epenet@users.noreply.github.com> * Removing some Black automatic formatting. --------- Co-authored-by: epenet <6771947+epenet@users.noreply.github.com> --- homeassistant/components/supla/__init__.py | 1 + homeassistant/components/supla/cover.py | 19 ++++++++++--------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/homeassistant/components/supla/__init__.py b/homeassistant/components/supla/__init__.py index 72956228948..96fe8f39aa9 100644 --- a/homeassistant/components/supla/__init__.py +++ b/homeassistant/components/supla/__init__.py @@ -30,6 +30,7 @@ SCAN_INTERVAL = timedelta(seconds=10) SUPLA_FUNCTION_HA_CMP_MAP = { "CONTROLLINGTHEROLLERSHUTTER": Platform.COVER, "CONTROLLINGTHEGATE": Platform.COVER, + "CONTROLLINGTHEGARAGEDOOR": Platform.COVER, "LIGHTSWITCH": Platform.SWITCH, } SUPLA_FUNCTION_NONE = "NONE" diff --git a/homeassistant/components/supla/cover.py b/homeassistant/components/supla/cover.py index c6c1d9c07db..df4e9c7e109 100644 --- a/homeassistant/components/supla/cover.py +++ b/homeassistant/components/supla/cover.py @@ -16,6 +16,7 @@ _LOGGER = logging.getLogger(__name__) SUPLA_SHUTTER = "CONTROLLINGTHEROLLERSHUTTER" SUPLA_GATE = "CONTROLLINGTHEGATE" +SUPLA_GARAGE_DOOR = "CONTROLLINGTHEGARAGEDOOR" async def async_setup_platform( @@ -44,9 +45,9 @@ async def async_setup_platform( ) ) - elif device_name == SUPLA_GATE: + elif device_name in {SUPLA_GATE, SUPLA_GARAGE_DOOR}: entities.append( - SuplaGateDoor( + SuplaDoor( device, hass.data[DOMAIN][SUPLA_SERVERS][server_name], hass.data[DOMAIN][SUPLA_COORDINATORS][server_name], @@ -90,33 +91,33 @@ class SuplaCover(SuplaChannel, CoverEntity): await self.async_action("STOP") -class SuplaGateDoor(SuplaChannel, CoverEntity): - """Representation of a Supla gate door.""" +class SuplaDoor(SuplaChannel, CoverEntity): + """Representation of a Supla door.""" @property def is_closed(self) -> bool | None: - """Return if the gate is closed or not.""" + """Return if the door is closed or not.""" state = self.channel_data.get("state") if state and "hi" in state: return state.get("hi") return None async def async_open_cover(self, **kwargs: Any) -> None: - """Open the gate.""" + """Open the door.""" if self.is_closed: await self.async_action("OPEN_CLOSE") async def async_close_cover(self, **kwargs: Any) -> None: - """Close the gate.""" + """Close the door.""" if not self.is_closed: await self.async_action("OPEN_CLOSE") async def async_stop_cover(self, **kwargs: Any) -> None: - """Stop the gate.""" + """Stop the door.""" await self.async_action("OPEN_CLOSE") async def async_toggle(self, **kwargs: Any) -> None: - """Toggle the gate.""" + """Toggle the door.""" await self.async_action("OPEN_CLOSE") @property