Change cover state to enum (#2348)

* Change cover state to enum

* Update date

* Add link

* states link
This commit is contained in:
G Johansson 2024-10-08 20:14:56 +02:00 committed by GitHub
parent 3188f4996a
commit a4bde2c9d1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 26 additions and 9 deletions

View File

@ -0,0 +1,15 @@
---
author: G Johansson
authorURL: https://github.com/gjohansson-ST
authorImageURL: https://avatars.githubusercontent.com/u/62932417?v=4
authorTwitter: GJohansson
title: "Deprecating state constants for cover"
---
As of Home Assistant Core 2024.11, the constants used to return state in `CoverEntity` are deprecated and replaced by the `CoverState` enum.
There is a one-year deprecation period, and the constants will stop working from 2025.11 to ensure all custom integration authors have time to adjust.
As the `state` property is not meant to be overwritten, in most cases this change will only affect other Entity properties or tests rather than the `state` property.
More details can be found in the [cover documentation](/docs/core/entity/cover#states).

View File

@ -19,6 +19,17 @@ Properties should always only return information from memory and not do I/O (lik
| is_closing | <code>bool &#124; None</code> | `None` | If the cover is closing or not. Used to determine `state`. | is_closing | <code>bool &#124; None</code> | `None` | If the cover is closing or not. Used to determine `state`.
| is_opening | <code>bool &#124; None</code> | `None` | If the cover is opening or not. Used to determine `state`. | is_opening | <code>bool &#124; None</code> | `None` | If the cover is opening or not. Used to determine `state`.
### States
The state is defined by setting the above properties. The resulting state is using the `CoverState` enum to return one of the below members.
| Value | Description |
|-------------|--------------------------------------------------------------------|
| `CLOSED` | The cover is closed. |
| `CLOSING` | The cover is closing. |
| `OPENING` | The cover is opening. |
| `OPEN` | The cover is open. |
### Device classes ### Device classes
| Constant | Description | Constant | Description
@ -34,15 +45,6 @@ Properties should always only return information from memory and not do I/O (lik
| `CoverDeviceClass.SHUTTER` | Control of shutters, which are linked slats that swing out/in to cover an opening or may be tilted to partially cover an opening, such as indoor or exterior window shutters. | `CoverDeviceClass.SHUTTER` | Control of shutters, which are linked slats that swing out/in to cover an opening or may be tilted to partially cover an opening, such as indoor or exterior window shutters.
| `CoverDeviceClass.WINDOW` | Control of a physical window that opens and closes or may tilt. | `CoverDeviceClass.WINDOW` | Control of a physical window that opens and closes or may tilt.
### States
| Constant | Description
|----------|------------------------|
| `STATE_OPENING` | The cover is in the process of opening to reach a set position.
| `STATE_OPEN` | The cover has reached the open position.
| `STATE_CLOSING` | The cover is in the process of closing to reach a set position.
| `STATE_CLOSED` | The cover has reach the closed position.
## Supported features ## Supported features
Supported features are defined by using values in the `CoverEntityFeature` enum Supported features are defined by using values in the `CoverEntityFeature` enum