Skip to content

Commit

Permalink
Use attributes in satel_integra alarm (home-assistant#74103)
Browse files Browse the repository at this point in the history
  • Loading branch information
epenet authored Jun 28, 2022
1 parent 8bed2e6 commit 3b30d8a
Showing 1 changed file with 8 additions and 26 deletions.
34 changes: 8 additions & 26 deletions homeassistant/components/satel_integra/alarm_control_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,17 @@ async def async_setup_platform(
class SatelIntegraAlarmPanel(alarm.AlarmControlPanelEntity):
"""Representation of an AlarmDecoder-based alarm panel."""

_attr_code_format = alarm.CodeFormat.NUMBER
_attr_should_poll = False
_attr_state: str | None
_attr_supported_features = (
AlarmControlPanelEntityFeature.ARM_HOME
| AlarmControlPanelEntityFeature.ARM_AWAY
)

def __init__(self, controller, name, arm_home_mode, partition_id):
"""Initialize the alarm panel."""
self._name = name
self._state = None
self._attr_name = name
self._arm_home_mode = arm_home_mode
self._partition_id = partition_id
self._satel = controller
Expand All @@ -89,8 +91,8 @@ def _update_alarm_status(self):
"""Handle alarm status update."""
state = self._read_alarm_state()
_LOGGER.debug("Got status update, current status: %s", state)
if state != self._state:
self._state = state
if state != self._attr_state:
self._attr_state = state
self.async_write_ha_state()
else:
_LOGGER.debug("Ignoring alarm status message, same state")
Expand Down Expand Up @@ -129,35 +131,15 @@ def _read_alarm_state(self):

return hass_alarm_status

@property
def name(self):
"""Return the name of the device."""
return self._name

@property
def should_poll(self):
"""Return the polling state."""
return False

@property
def code_format(self):
"""Return the regex for code format or None if no code is required."""
return alarm.CodeFormat.NUMBER

@property
def state(self):
"""Return the state of the device."""
return self._state

async def async_alarm_disarm(self, code: str | None = None) -> None:
"""Send disarm command."""
if not code:
_LOGGER.debug("Code was empty or None")
return

clear_alarm_necessary = self._state == STATE_ALARM_TRIGGERED
clear_alarm_necessary = self._attr_state == STATE_ALARM_TRIGGERED

_LOGGER.debug("Disarming, self._state: %s", self._state)
_LOGGER.debug("Disarming, self._attr_state: %s", self._attr_state)

await self._satel.disarm(code, [self._partition_id])

Expand Down

0 comments on commit 3b30d8a

Please sign in to comment.