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

fix: use AlarmControlPanelState constants (#2657) #2661

Merged
merged 1 commit into from
Nov 2, 2024
Merged
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
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
Loading