Skip to content

Commit

Permalink
Merge pull request #325 from JoDehli/319-state_alarm_-was-used-from-l…
Browse files Browse the repository at this point in the history
…oxone

319 state alarm  was used from loxone
  • Loading branch information
JoDehli authored Nov 10, 2024
2 parents d447e8e + c065777 commit f3078e1
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions custom_components/loxone/alarm_control_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,12 @@
import homeassistant.helpers.config_validation as cv
import voluptuous as vol
from homeassistant.components.alarm_control_panel import (
PLATFORM_SCHEMA, AlarmControlPanelEntity)
PLATFORM_SCHEMA, AlarmControlPanelEntity, AlarmControlPanelState)
from homeassistant.components.alarm_control_panel.const import (
AlarmControlPanelEntityFeature, CodeFormat)
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import (CONF_CODE, CONF_NAME, CONF_PASSWORD,
CONF_USERNAME, STATE_ALARM_ARMED_AWAY,
STATE_ALARM_ARMED_HOME, STATE_ALARM_ARMING,
STATE_ALARM_DISARMED, STATE_ALARM_TRIGGERED)
CONF_USERNAME)
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
Expand Down Expand Up @@ -83,6 +81,7 @@ def __init__(self, **kwargs):
self._attr_device_info = get_or_create_device(
self.unique_id, self.name, "Alarm", self.room
)

@property
def supported_features(self):
return (
Expand Down Expand Up @@ -192,7 +191,8 @@ async def async_alarm_arm_home(self, code=None):
"""Send arm home command."""
if self.isSecured:
self.hass.bus.async_fire(
SECUREDSENDDOMAIN, dict(uuid=self.uuidAction, value="delayedon/0", code=code)
SECUREDSENDDOMAIN,
dict(uuid=self.uuidAction, value="delayedon/0", code=code),
)
else:
self.hass.bus.async_fire(
Expand All @@ -204,7 +204,8 @@ async def async_alarm_arm_away(self, code=None):
"""Send arm away command."""
if self.isSecured:
self.hass.bus.async_fire(
SECUREDSENDDOMAIN, dict(uuid=self.uuidAction, value="delayedon/1", code=code)
SECUREDSENDDOMAIN,
dict(uuid=self.uuidAction, value="delayedon/1", code=code),
)
else:
self.hass.bus.async_fire(
Expand All @@ -213,17 +214,18 @@ async def async_alarm_arm_away(self, code=None):
self.async_schedule_update_ha_state()

@property
def state(self):
"""Return the state of the entity."""
def alarm_state(self) -> AlarmControlPanelState | None:
"""Return the state of the device."""
if self._level >= 1.0:
return STATE_ALARM_TRIGGERED
return AlarmControlPanelState.TRIGGERED
if self._armed_delay or self._armed_at:
return STATE_ALARM_ARMING
return AlarmControlPanelState.ARMING
if self._state and self._disabled_move:
return STATE_ALARM_ARMED_HOME
return AlarmControlPanelState.ARMED_HOME
if self._state:
return STATE_ALARM_ARMED_AWAY
return STATE_ALARM_DISARMED
return AlarmControlPanelState.ARMED_AWAY
return AlarmControlPanelState.DISARMED


@property
def extra_state_attributes(self):
Expand Down

0 comments on commit f3078e1

Please sign in to comment.