From a4bde2c9d1aa12349fb354f9b0bd50ef89fd1caa Mon Sep 17 00:00:00 2001 From: G Johansson Date: Tue, 8 Oct 2024 20:14:56 +0200 Subject: [PATCH] Change cover state to enum (#2348) * Change cover state to enum * Update date * Add link * states link --- ...10-08-state-constants-cover-deprecation.md | 15 ++++++++++++++ docs/core/entity/cover.md | 20 ++++++++++--------- 2 files changed, 26 insertions(+), 9 deletions(-) create mode 100644 blog/2024-10-08-state-constants-cover-deprecation.md diff --git a/blog/2024-10-08-state-constants-cover-deprecation.md b/blog/2024-10-08-state-constants-cover-deprecation.md new file mode 100644 index 00000000..080022a2 --- /dev/null +++ b/blog/2024-10-08-state-constants-cover-deprecation.md @@ -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). \ No newline at end of file diff --git a/docs/core/entity/cover.md b/docs/core/entity/cover.md index 64bbd0f3..49e8c6ee 100644 --- a/docs/core/entity/cover.md +++ b/docs/core/entity/cover.md @@ -19,6 +19,17 @@ Properties should always only return information from memory and not do I/O (lik | is_closing | bool | None | `None` | If the cover is closing or not. Used to determine `state`. | is_opening | bool | None | `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 | 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.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 are defined by using values in the `CoverEntityFeature` enum