Skip to content

Commit

Permalink
🔧 fix deprecated warnings (#1942)
Browse files Browse the repository at this point in the history
  • Loading branch information
hmmbob authored Nov 14, 2024
1 parent d487b50 commit f1526ea
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 12 deletions.
17 changes: 5 additions & 12 deletions custom_components/xiaomi_miot/alarm_control_panel.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
"""Support alarm_control_panel entity for Xiaomi Miot."""
import logging

from homeassistant.const import (
STATE_ALARM_ARMED_AWAY,
STATE_ALARM_ARMED_HOME,
STATE_ALARM_ARMED_NIGHT,
STATE_ALARM_DISARMED,
STATE_ALARM_TRIGGERED,
)
from homeassistant.components.alarm_control_panel import (
DOMAIN as ENTITY_DOMAIN,
AlarmControlPanelEntity,
Expand Down Expand Up @@ -89,17 +82,17 @@ def update_state(self):
if des is not None:
des = f'{des}'.lower()
if 'basic' in des:
self._attr_state = STATE_ALARM_DISARMED
self._attr_state = AlarmControlPanelState.DISARMED
elif 'home' in des:
self._attr_state = STATE_ALARM_ARMED_HOME
self._attr_state = AlarmControlPanelState.ARMED_HOME
elif 'away' in des:
self._attr_state = STATE_ALARM_ARMED_AWAY
self._attr_state = AlarmControlPanelState.ARMED_AWAY
elif 'sleep' in des:
self._attr_state = STATE_ALARM_ARMED_NIGHT
self._attr_state = AlarmControlPanelState.ARMED_NIGHT
if self._is_mgl03:
val = self._state_attrs.get('arming.alarm')
if val:
self._attr_state = STATE_ALARM_TRIGGERED
self._attr_state = AlarmControlPanelState.TRIGGERED
return self._attr_state

def set_arm_mode(self, mode):
Expand Down
18 changes: 18 additions & 0 deletions custom_components/xiaomi_miot/core/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,21 @@ class CameraState(StrEnum):
from homeassistant.core_config import DATA_CUSTOMIZE
except (ModuleNotFoundError, ImportError):
from homeassistant.helpers.entity import DATA_CUSTOMIZE

try:
# hass 2024.11
from homeassistant.components.alarm_control_panel import AlarmControlPanelState
except (ModuleNotFoundError, ImportError):
class AlarmControlPanelState(StrEnum):
"""Alarm control panel entity states."""

DISARMED = "disarmed"
ARMED_HOME = "armed_home"
ARMED_AWAY = "armed_away"
ARMED_NIGHT = "armed_night"
ARMED_VACATION = "armed_vacation"
ARMED_CUSTOM_BYPASS = "armed_custom_bypass"
PENDING = "pending"
ARMING = "arming"
DISARMING = "disarming"
TRIGGERED = "triggered"

0 comments on commit f1526ea

Please sign in to comment.