mirror of
https://github.com/home-assistant/core.git
synced 2025-07-16 09:47:13 +00:00
Use attributes in ifttt alarm (#74107)
This commit is contained in:
parent
389664e37c
commit
03d2d50393
@ -127,6 +127,7 @@ def setup_platform(
|
|||||||
class IFTTTAlarmPanel(AlarmControlPanelEntity):
|
class IFTTTAlarmPanel(AlarmControlPanelEntity):
|
||||||
"""Representation of an alarm control panel controlled through IFTTT."""
|
"""Representation of an alarm control panel controlled through IFTTT."""
|
||||||
|
|
||||||
|
_attr_assumed_state = True
|
||||||
_attr_supported_features = (
|
_attr_supported_features = (
|
||||||
AlarmControlPanelEntityFeature.ARM_HOME
|
AlarmControlPanelEntityFeature.ARM_HOME
|
||||||
| AlarmControlPanelEntityFeature.ARM_AWAY
|
| AlarmControlPanelEntityFeature.ARM_AWAY
|
||||||
@ -145,7 +146,7 @@ class IFTTTAlarmPanel(AlarmControlPanelEntity):
|
|||||||
optimistic,
|
optimistic,
|
||||||
):
|
):
|
||||||
"""Initialize the alarm control panel."""
|
"""Initialize the alarm control panel."""
|
||||||
self._name = name
|
self._attr_name = name
|
||||||
self._code = code
|
self._code = code
|
||||||
self._code_arm_required = code_arm_required
|
self._code_arm_required = code_arm_required
|
||||||
self._event_away = event_away
|
self._event_away = event_away
|
||||||
@ -153,25 +154,9 @@ class IFTTTAlarmPanel(AlarmControlPanelEntity):
|
|||||||
self._event_night = event_night
|
self._event_night = event_night
|
||||||
self._event_disarm = event_disarm
|
self._event_disarm = event_disarm
|
||||||
self._optimistic = optimistic
|
self._optimistic = optimistic
|
||||||
self._state = None
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self):
|
def code_format(self) -> CodeFormat | None:
|
||||||
"""Return the name of the device."""
|
|
||||||
return self._name
|
|
||||||
|
|
||||||
@property
|
|
||||||
def state(self):
|
|
||||||
"""Return the state of the device."""
|
|
||||||
return self._state
|
|
||||||
|
|
||||||
@property
|
|
||||||
def assumed_state(self):
|
|
||||||
"""Notify that this platform return an assumed state."""
|
|
||||||
return True
|
|
||||||
|
|
||||||
@property
|
|
||||||
def code_format(self):
|
|
||||||
"""Return one or more digits/characters."""
|
"""Return one or more digits/characters."""
|
||||||
if self._code is None:
|
if self._code is None:
|
||||||
return None
|
return None
|
||||||
@ -210,13 +195,13 @@ class IFTTTAlarmPanel(AlarmControlPanelEntity):
|
|||||||
self.hass.services.call(DOMAIN, SERVICE_TRIGGER, data)
|
self.hass.services.call(DOMAIN, SERVICE_TRIGGER, data)
|
||||||
_LOGGER.debug("Called IFTTT integration to trigger event %s", event)
|
_LOGGER.debug("Called IFTTT integration to trigger event %s", event)
|
||||||
if self._optimistic:
|
if self._optimistic:
|
||||||
self._state = state
|
self._attr_state = state
|
||||||
|
|
||||||
def push_alarm_state(self, value):
|
def push_alarm_state(self, value):
|
||||||
"""Push the alarm state to the given value."""
|
"""Push the alarm state to the given value."""
|
||||||
if value in ALLOWED_STATES:
|
if value in ALLOWED_STATES:
|
||||||
_LOGGER.debug("Pushed the alarm state to %s", value)
|
_LOGGER.debug("Pushed the alarm state to %s", value)
|
||||||
self._state = value
|
self._attr_state = value
|
||||||
|
|
||||||
def _check_code(self, code):
|
def _check_code(self, code: str | None) -> bool:
|
||||||
return self._code is None or self._code == code
|
return self._code is None or self._code == code
|
||||||
|
Loading…
x
Reference in New Issue
Block a user