Skip to content

Commit

Permalink
Merge pull request #2661 from alandtse/dev
Browse files Browse the repository at this point in the history
fix: use AlarmControlPanelState constants (#2657)
  • Loading branch information
alandtse authored Nov 2, 2024
2 parents 3b46271 + 0876d5c commit 30344e8
Showing 1 changed file with 8 additions and 15 deletions.
23 changes: 8 additions & 15 deletions custom_components/alexa_media/alarm_control_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,8 @@
from typing import List, Optional

from alexapy import hide_email, hide_serial
from homeassistant.const import (
CONF_EMAIL,
STATE_ALARM_ARMED_AWAY,
STATE_ALARM_DISARMED,
STATE_UNAVAILABLE,
)
from homeassistant.components.alarm_control_panel import AlarmControlPanelEntity
from homeassistant.const import CONF_EMAIL, STATE_UNAVAILABLE
from homeassistant.exceptions import ConfigEntryNotReady
from homeassistant.helpers.update_coordinator import CoordinatorEntity

Expand All @@ -34,13 +30,12 @@
from .helpers import _catch_login_errors, add_devices

try:
from homeassistant.components.alarm_control_panel import (
AlarmControlPanelEntity as AlarmControlPanel,
)
except ImportError:
from homeassistant.components.alarm_control_panel import AlarmControlPanel

from homeassistant.components.alarm_control_panel import AlarmControlPanelState

STATE_ALARM_ARMED_AWAY = AlarmControlPanelState.ARMED_AWAY
STATE_ALARM_DISARMED = AlarmControlPanelState.DISARMED
except ImportError:
from homeassistant.const import STATE_ALARM_ARMED_AWAY, STATE_ALARM_DISARMED
_LOGGER = logging.getLogger(__name__)

DEPENDENCIES = [ALEXA_DOMAIN]
Expand Down Expand Up @@ -135,7 +130,7 @@ async def async_unload_entry(hass, entry) -> bool:
return True


class AlexaAlarmControlPanel(AlarmControlPanel, AlexaMedia, CoordinatorEntity):
class AlexaAlarmControlPanel(AlarmControlPanelEntity, AlexaMedia, CoordinatorEntity):
"""Implementation of Alexa Media Player alarm control panel."""

def __init__(self, login, coordinator, guard_entity, media_players=None) -> None:
Expand Down Expand Up @@ -224,8 +219,6 @@ def state(self):
)
if _state == "ARMED_AWAY":
return STATE_ALARM_ARMED_AWAY
if _state == "ARMED_STAY":
return STATE_ALARM_DISARMED
return STATE_ALARM_DISARMED

@property
Expand Down

0 comments on commit 30344e8

Please sign in to comment.