Implement new state property for alarm_control_panel which is using an enum (#126283)

* Alarm state from enum

* Fixes

* Set final

* Fix rebase

* Test const

* Fix breaking version

* Fix other for alarm_control_panel

* Fix integrations

* More

* More

* More

* More

* Fix zha

* Replace _attr_state

* Fix alarm_control_panel

* Fix tests

* Fixes

* Mods

* Change some

* More

* More

* More

* Tests

* Last tests

* Return enum

* Fix zha

* Remove not needed check

* Fix wording

* Fix homekit

* Mod prometheus

* Fix mypy

* Fix homekit

* Fix ifttt
This commit is contained in:
G Johansson
2024-10-21 22:54:27 +02:00
committed by GitHub
parent 59ad69b637
commit cdfec7ebb4
90 changed files with 2010 additions and 1810 deletions

View File

@@ -8,7 +8,7 @@ from unittest.mock import Mock, patch
import pytest
from homeassistant import const
from homeassistant.components import lock, sensor
from homeassistant.components import alarm_control_panel, lock, sensor
from .common import (
extract_stack_to_frame,
@@ -218,6 +218,38 @@ def test_deprecated_constants_lock(
)
def _create_tuples_alarm_states(
enum: type[Enum], constant_prefix: str, remove_in_version: str
) -> list[tuple[Enum, str]]:
return [
(enum_field, constant_prefix, remove_in_version)
for enum_field in enum
if enum_field
not in [
lock.LockState.OPEN,
lock.LockState.OPENING,
]
]
@pytest.mark.parametrize(
("enum", "constant_prefix", "remove_in_version"),
_create_tuples_lock_states(
alarm_control_panel.AlarmControlPanelState, "STATE_ALARM_", "2025.11"
),
)
def test_deprecated_constants_alarm(
caplog: pytest.LogCaptureFixture,
enum: Enum,
constant_prefix: str,
remove_in_version: str,
) -> None:
"""Test deprecated constants."""
import_and_test_deprecated_constant_enum(
caplog, const, enum, constant_prefix, remove_in_version
)
def test_deprecated_unit_of_conductivity_alias() -> None:
"""Test UnitOfConductivity deprecation."""