Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use AlarmControlPanelState introduced in HA 2024.11 #153

Merged
merged 1 commit into from
Nov 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 14 additions & 22 deletions custom_components/vivint/alarm_control_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}


Expand Down Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion hacs.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Vivint",
"homeassistant": "2023.8.0",
"homeassistant": "2024.11.0",
"render_readme": true,
"zip_release": true,
"filename": "vivint.zip"
Expand Down
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# Home Assistant
homeassistant>=2024.4
homeassistant>=2024.11b
python-dateutil
numpy
PyTurboJPEG

# Integration
vivintpy
Expand Down