Change lock state is enum (#2329)

* Change lock state is enum

* Add blog

* Update blog/2024-09-23-state-constants-lock-deprecation.md

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* Apply suggestions from code review

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>

---------

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
This commit is contained in:
G Johansson 2024-09-24 13:06:54 +02:00 committed by GitHub
parent ec469357db
commit 22c1aa781f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 27 additions and 0 deletions

View File

@ -0,0 +1,13 @@
---
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 lock"
---
As of Home Assistant Core 2024.10, the constants used to return state in `LockEntity` are deprecated and replaced by the `LockState` enum.
There is a one-year deprecation period, and the constants will stop working from 2025.10 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.

View File

@ -22,6 +22,20 @@ Properties should always only return information from memory and not do I/O (lik
| is_opening | bool | None | Indication of whether the lock is currently opening. Used to determine `state`.
| is_open | bool | None | Indication of whether the lock is currently open. Used to determine `state`.
### States
The state is defined by setting the above properties. The resulting state is using the `LockState` enum to return one of the below members.
| Value | Description |
|-------------|--------------------------------------------------------------------|
| `LOCKED` | The lock is locked. |
| `LOCKING` | The lock is locking. |
| `UNLOCKING` | The lock is unlocking. |
| `UNLOCKED` | The lock is unlocked. |
| `JAMMED` | The lock is currently jammed. |
| `OPENING` | The lock is opening. |
| `OPEN` | The lock is open. |
## Supported features
Supported features are defined by using values in the `LockEntityFeature` enum