From f3e8ccd0b27413ce890627e8071d18553c9e5c2d Mon Sep 17 00:00:00 2001 From: Nathan Spencer Date: Fri, 1 Nov 2024 22:21:19 +0000 Subject: [PATCH] Use AlarmControlPanelState introduced in HA 2024.11 --- .../vivint/alarm_control_panel.py | 36 ++++++++----------- hacs.json | 2 +- requirements.txt | 3 +- 3 files changed, 17 insertions(+), 24 deletions(-) diff --git a/custom_components/vivint/alarm_control_panel.py b/custom_components/vivint/alarm_control_panel.py index 3bbf987..65226f3 100644 --- a/custom_components/vivint/alarm_control_panel.py +++ b/custom_components/vivint/alarm_control_panel.py @@ -11,37 +11,29 @@ DOMAIN as PLATFORM, AlarmControlPanelEntity, AlarmControlPanelEntityFeature as Feature, + AlarmControlPanelState, CodeFormat, ) -from homeassistant.const import ( - STATE_ALARM_ARMED_AWAY, - STATE_ALARM_ARMED_HOME, - STATE_ALARM_ARMING, - STATE_ALARM_DISARMED, - STATE_ALARM_PENDING, - STATE_ALARM_TRIGGERED, -) from homeassistant.core import HomeAssistant from homeassistant.helpers import entity_registry as er from homeassistant.helpers.entity_platform import AddEntitiesCallback -from homeassistant.helpers.typing import StateType from . import VivintConfigEntry from .const import CONF_DISARM_CODE, DOMAIN from .hub import VivintEntity, VivintHub ARMED_STATE_MAP = { - ArmedState.DISARMED: STATE_ALARM_DISARMED, - ArmedState.ARMING_AWAY_IN_EXIT_DELAY: STATE_ALARM_ARMING, - ArmedState.ARMING_STAY_IN_EXIT_DELAY: STATE_ALARM_ARMING, - ArmedState.ARMED_STAY: STATE_ALARM_ARMED_HOME, - ArmedState.ARMED_AWAY: STATE_ALARM_ARMED_AWAY, - ArmedState.ARMED_STAY_IN_ENTRY_DELAY: STATE_ALARM_PENDING, - ArmedState.ARMED_AWAY_IN_ENTRY_DELAY: STATE_ALARM_PENDING, - ArmedState.ALARM: STATE_ALARM_TRIGGERED, - ArmedState.ALARM_FIRE: STATE_ALARM_TRIGGERED, - ArmedState.DISABLED: STATE_ALARM_DISARMED, - ArmedState.WALK_TEST: STATE_ALARM_DISARMED, + ArmedState.DISARMED: AlarmControlPanelState.DISARMED, + ArmedState.ARMING_AWAY_IN_EXIT_DELAY: AlarmControlPanelState.ARMING, + ArmedState.ARMING_STAY_IN_EXIT_DELAY: AlarmControlPanelState.ARMING, + ArmedState.ARMED_STAY: AlarmControlPanelState.ARMED_HOME, + ArmedState.ARMED_AWAY: AlarmControlPanelState.ARMED_AWAY, + ArmedState.ARMED_STAY_IN_ENTRY_DELAY: AlarmControlPanelState.PENDING, + ArmedState.ARMED_AWAY_IN_ENTRY_DELAY: AlarmControlPanelState.PENDING, + ArmedState.ALARM: AlarmControlPanelState.TRIGGERED, + ArmedState.ALARM_FIRE: AlarmControlPanelState.TRIGGERED, + ArmedState.DISABLED: AlarmControlPanelState.DISARMED, + ArmedState.WALK_TEST: AlarmControlPanelState.DISARMED, } @@ -92,8 +84,8 @@ def __init__( self._disarm_code = disarm_code @property - def state(self) -> StateType: - """Return the state of the alarm control panel.""" + def alarm_state(self) -> AlarmControlPanelState | None: + """Return the current alarm control panel entity state.""" return ARMED_STATE_MAP.get(self.device.state) async def async_alarm_disarm(self, code: str | None = None) -> None: diff --git a/hacs.json b/hacs.json index b2321d2..48a1aac 100644 --- a/hacs.json +++ b/hacs.json @@ -1,6 +1,6 @@ { "name": "Vivint", - "homeassistant": "2023.8.0", + "homeassistant": "2024.11.0", "render_readme": true, "zip_release": true, "filename": "vivint.zip" diff --git a/requirements.txt b/requirements.txt index c5ce57c..9239df7 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,7 +1,8 @@ # Home Assistant -homeassistant>=2024.4 +homeassistant>=2024.11b python-dateutil numpy +PyTurboJPEG # Integration vivintpy