From fab61cda3ea8b75f5b27abb9255bc226400ef716 Mon Sep 17 00:00:00 2001 From: Felipe Santos Date: Wed, 8 Jan 2025 12:12:07 -0300 Subject: [PATCH] Add support for cover `toggle_action` --- aioesphomeapi/api.proto | 1 + aioesphomeapi/client.py | 3 +++ aioesphomeapi/model.py | 1 + 3 files changed, 5 insertions(+) diff --git a/aioesphomeapi/api.proto b/aioesphomeapi/api.proto index e527cf04..549ef7ba 100644 --- a/aioesphomeapi/api.proto +++ b/aioesphomeapi/api.proto @@ -300,6 +300,7 @@ message ListEntitiesCoverResponse { string icon = 10; EntityCategory entity_category = 11; bool supports_stop = 12; + bool supports_toggle = 13; } enum LegacyCoverState { diff --git a/aioesphomeapi/client.py b/aioesphomeapi/client.py index ddfe3122..79ea9a1a 100644 --- a/aioesphomeapi/client.py +++ b/aioesphomeapi/client.py @@ -961,6 +961,7 @@ def send_home_assistant_state( def cover_command( self, key: int, + toggle: bool = False, position: float | None = None, tilt: float | None = None, stop: bool = False, @@ -971,6 +972,8 @@ def cover_command( if TYPE_CHECKING: assert apiv is not None if apiv >= APIVersion(1, 1): + if toggle: + req.toggle = toggle if position is not None: req.has_position = True req.position = position diff --git a/aioesphomeapi/model.py b/aioesphomeapi/model.py index df2ec727..0383c47d 100644 --- a/aioesphomeapi/model.py +++ b/aioesphomeapi/model.py @@ -222,6 +222,7 @@ class BinarySensorState(EntityState): class CoverInfo(EntityInfo): assumed_state: bool = False supports_stop: bool = False + supports_toggle: bool = False supports_position: bool = False supports_tilt: bool = False device_class: str = ""