From abe60375b378b0f7812348b3ba0f446bb3fd269b Mon Sep 17 00:00:00 2001
From: Alexander Momchilov <amomchilov@users.noreply.github.com>
Date: Tue, 28 Mar 2023 10:43:47 -0400
Subject: [PATCH] Disable esphome stopping a cover if the cover doesn't support
 stopping (#80104)

* Make "CoverEntityFeature.STOP" conditional

* Check APIVersion before checking false by default flag

* sort

---------

Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com>
---
 homeassistant/components/esphome/cover.py | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/homeassistant/components/esphome/cover.py b/homeassistant/components/esphome/cover.py
index 99d5f16b271..9d82b285291 100644
--- a/homeassistant/components/esphome/cover.py
+++ b/homeassistant/components/esphome/cover.py
@@ -3,7 +3,7 @@ from __future__ import annotations
 
 from typing import Any
 
-from aioesphomeapi import CoverInfo, CoverOperation, CoverState
+from aioesphomeapi import APIVersion, CoverInfo, CoverOperation, CoverState
 
 from homeassistant.components.cover import (
     ATTR_POSITION,
@@ -41,9 +41,10 @@ class EsphomeCover(EsphomeEntity[CoverInfo, CoverState], CoverEntity):
     @property
     def supported_features(self) -> CoverEntityFeature:
         """Flag supported features."""
-        flags = (
-            CoverEntityFeature.OPEN | CoverEntityFeature.CLOSE | CoverEntityFeature.STOP
-        )
+        flags = CoverEntityFeature.OPEN | CoverEntityFeature.CLOSE
+
+        if self._api_version < APIVersion(1, 8) or self._static_info.supports_stop:
+            flags |= CoverEntityFeature.STOP
         if self._static_info.supports_position:
             flags |= CoverEntityFeature.SET_POSITION
         if self._static_info.supports_tilt:
-- 
GitLab