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>
This commit is contained in:
Alexander Momchilov 2023-03-28 10:43:47 -04:00 committed by GitHub
parent 3662c651c9
commit abe60375b3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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: