Adjust type hints in component alarm methods (#74092)
* Adjust type hints in component alarm methods * Undo related change * Undo related change
This commit is contained in:
parent
800bae68a8
commit
8e1ec07f3d
23 changed files with 125 additions and 107 deletions
|
@ -1,4 +1,6 @@
|
|||
"""Support for Agent DVR Alarm Control Panels."""
|
||||
from __future__ import annotations
|
||||
|
||||
from homeassistant.components.alarm_control_panel import (
|
||||
AlarmControlPanelEntity,
|
||||
AlarmControlPanelEntityFeature,
|
||||
|
@ -58,7 +60,7 @@ class AgentBaseStation(AlarmControlPanelEntity):
|
|||
sw_version=client.version,
|
||||
)
|
||||
|
||||
async def async_update(self):
|
||||
async def async_update(self) -> None:
|
||||
"""Update the state of the device."""
|
||||
await self._client.update()
|
||||
self._attr_available = self._client.is_available
|
||||
|
@ -76,24 +78,24 @@ class AgentBaseStation(AlarmControlPanelEntity):
|
|||
else:
|
||||
self._attr_state = STATE_ALARM_DISARMED
|
||||
|
||||
async def async_alarm_disarm(self, code=None):
|
||||
async def async_alarm_disarm(self, code: str | None = None) -> None:
|
||||
"""Send disarm command."""
|
||||
await self._client.disarm()
|
||||
self._attr_state = STATE_ALARM_DISARMED
|
||||
|
||||
async def async_alarm_arm_away(self, code=None):
|
||||
async def async_alarm_arm_away(self, code: str | None = None) -> None:
|
||||
"""Send arm away command. Uses custom mode."""
|
||||
await self._client.arm()
|
||||
await self._client.set_active_profile(CONF_AWAY_MODE_NAME)
|
||||
self._attr_state = STATE_ALARM_ARMED_AWAY
|
||||
|
||||
async def async_alarm_arm_home(self, code=None):
|
||||
async def async_alarm_arm_home(self, code: str | None = None) -> None:
|
||||
"""Send arm home command. Uses custom mode."""
|
||||
await self._client.arm()
|
||||
await self._client.set_active_profile(CONF_HOME_MODE_NAME)
|
||||
self._attr_state = STATE_ALARM_ARMED_HOME
|
||||
|
||||
async def async_alarm_arm_night(self, code=None):
|
||||
async def async_alarm_arm_night(self, code: str | None = None) -> None:
|
||||
"""Send arm night command. Uses custom mode."""
|
||||
await self._client.arm()
|
||||
await self._client.set_active_profile(CONF_NIGHT_MODE_NAME)
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
"""Support for AlarmDecoder-based alarm control panels (Honeywell/DSC)."""
|
||||
from __future__ import annotations
|
||||
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.components.alarm_control_panel import (
|
||||
|
@ -91,7 +93,7 @@ class AlarmDecoderAlarmPanel(AlarmControlPanelEntity):
|
|||
self._attr_code_arm_required = code_arm_required
|
||||
self._alt_night_mode = alt_night_mode
|
||||
|
||||
async def async_added_to_hass(self):
|
||||
async def async_added_to_hass(self) -> None:
|
||||
"""Register callbacks."""
|
||||
self.async_on_remove(
|
||||
async_dispatcher_connect(
|
||||
|
@ -126,12 +128,12 @@ class AlarmDecoderAlarmPanel(AlarmControlPanelEntity):
|
|||
}
|
||||
self.schedule_update_ha_state()
|
||||
|
||||
def alarm_disarm(self, code=None):
|
||||
def alarm_disarm(self, code: str | None = None) -> None:
|
||||
"""Send disarm command."""
|
||||
if code:
|
||||
self._client.send(f"{code!s}1")
|
||||
|
||||
def alarm_arm_away(self, code=None):
|
||||
def alarm_arm_away(self, code: str | None = None) -> None:
|
||||
"""Send arm away command."""
|
||||
self._client.arm_away(
|
||||
code=code,
|
||||
|
@ -139,7 +141,7 @@ class AlarmDecoderAlarmPanel(AlarmControlPanelEntity):
|
|||
auto_bypass=self._auto_bypass,
|
||||
)
|
||||
|
||||
def alarm_arm_home(self, code=None):
|
||||
def alarm_arm_home(self, code: str | None = None) -> None:
|
||||
"""Send arm home command."""
|
||||
self._client.arm_home(
|
||||
code=code,
|
||||
|
@ -147,7 +149,7 @@ class AlarmDecoderAlarmPanel(AlarmControlPanelEntity):
|
|||
auto_bypass=self._auto_bypass,
|
||||
)
|
||||
|
||||
def alarm_arm_night(self, code=None):
|
||||
def alarm_arm_night(self, code: str | None = None) -> None:
|
||||
"""Send arm night command."""
|
||||
self._client.arm_night(
|
||||
code=code,
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
"""Support for Blink Alarm Control Panel."""
|
||||
from __future__ import annotations
|
||||
|
||||
import logging
|
||||
|
||||
from homeassistant.components.alarm_control_panel import (
|
||||
|
@ -51,7 +53,7 @@ class BlinkSyncModule(AlarmControlPanelEntity):
|
|||
identifiers={(DOMAIN, sync.serial)}, name=name, manufacturer=DEFAULT_BRAND
|
||||
)
|
||||
|
||||
def update(self):
|
||||
def update(self) -> None:
|
||||
"""Update the state of the device."""
|
||||
_LOGGER.debug("Updating Blink Alarm Control Panel %s", self._name)
|
||||
self.data.refresh()
|
||||
|
@ -63,12 +65,12 @@ class BlinkSyncModule(AlarmControlPanelEntity):
|
|||
self.sync.attributes[ATTR_ATTRIBUTION] = DEFAULT_ATTRIBUTION
|
||||
self._attr_extra_state_attributes = self.sync.attributes
|
||||
|
||||
def alarm_disarm(self, code=None):
|
||||
def alarm_disarm(self, code: str | None = None) -> None:
|
||||
"""Send disarm command."""
|
||||
self.sync.arm = False
|
||||
self.sync.refresh()
|
||||
|
||||
def alarm_arm_away(self, code=None):
|
||||
def alarm_arm_away(self, code: str | None = None) -> None:
|
||||
"""Send arm command."""
|
||||
self.sync.arm = True
|
||||
self.sync.refresh()
|
||||
|
|
|
@ -103,7 +103,7 @@ class Concord232Alarm(alarm.AlarmControlPanelEntity):
|
|||
"""Return the state of the device."""
|
||||
return self._state
|
||||
|
||||
def update(self):
|
||||
def update(self) -> None:
|
||||
"""Update values from API."""
|
||||
try:
|
||||
part = self._alarm.list_partitions()[0]
|
||||
|
@ -124,13 +124,13 @@ class Concord232Alarm(alarm.AlarmControlPanelEntity):
|
|||
else:
|
||||
self._state = STATE_ALARM_ARMED_AWAY
|
||||
|
||||
def alarm_disarm(self, code=None):
|
||||
def alarm_disarm(self, code: str | None = None) -> None:
|
||||
"""Send disarm command."""
|
||||
if not self._validate_code(code, STATE_ALARM_DISARMED):
|
||||
return
|
||||
self._alarm.disarm(code)
|
||||
|
||||
def alarm_arm_home(self, code=None):
|
||||
def alarm_arm_home(self, code: str | None = None) -> None:
|
||||
"""Send arm home command."""
|
||||
if not self._validate_code(code, STATE_ALARM_ARMED_HOME):
|
||||
return
|
||||
|
@ -139,7 +139,7 @@ class Concord232Alarm(alarm.AlarmControlPanelEntity):
|
|||
else:
|
||||
self._alarm.arm("stay")
|
||||
|
||||
def alarm_arm_away(self, code=None):
|
||||
def alarm_arm_away(self, code: str | None = None) -> None:
|
||||
"""Send arm away command."""
|
||||
if not self._validate_code(code, STATE_ALARM_ARMED_AWAY):
|
||||
return
|
||||
|
|
|
@ -79,7 +79,7 @@ class EgardiaAlarm(alarm.AlarmControlPanelEntity):
|
|||
self._rs_codes = rs_codes
|
||||
self._rs_port = rs_port
|
||||
|
||||
async def async_added_to_hass(self):
|
||||
async def async_added_to_hass(self) -> None:
|
||||
"""Add Egardiaserver callback if enabled."""
|
||||
if self._rs_enabled:
|
||||
_LOGGER.debug("Registering callback to Egardiaserver")
|
||||
|
@ -134,12 +134,12 @@ class EgardiaAlarm(alarm.AlarmControlPanelEntity):
|
|||
else:
|
||||
_LOGGER.error("Ignoring status")
|
||||
|
||||
def update(self):
|
||||
def update(self) -> None:
|
||||
"""Update the alarm status."""
|
||||
status = self._egardiasystem.getstate()
|
||||
self.parsestatus(status)
|
||||
|
||||
def alarm_disarm(self, code=None):
|
||||
def alarm_disarm(self, code: str | None = None) -> None:
|
||||
"""Send disarm command."""
|
||||
try:
|
||||
self._egardiasystem.alarm_disarm()
|
||||
|
@ -149,7 +149,7 @@ class EgardiaAlarm(alarm.AlarmControlPanelEntity):
|
|||
err,
|
||||
)
|
||||
|
||||
def alarm_arm_home(self, code=None):
|
||||
def alarm_arm_home(self, code: str | None = None) -> None:
|
||||
"""Send arm home command."""
|
||||
try:
|
||||
self._egardiasystem.alarm_arm_home()
|
||||
|
@ -160,7 +160,7 @@ class EgardiaAlarm(alarm.AlarmControlPanelEntity):
|
|||
err,
|
||||
)
|
||||
|
||||
def alarm_arm_away(self, code=None):
|
||||
def alarm_arm_away(self, code: str | None = None) -> None:
|
||||
"""Send arm away command."""
|
||||
try:
|
||||
self._egardiasystem.alarm_arm_away()
|
||||
|
|
|
@ -121,7 +121,7 @@ class EnvisalinkAlarm(EnvisalinkDevice, AlarmControlPanelEntity):
|
|||
_LOGGER.debug("Setting up alarm: %s", alarm_name)
|
||||
super().__init__(alarm_name, info, controller)
|
||||
|
||||
async def async_added_to_hass(self):
|
||||
async def async_added_to_hass(self) -> None:
|
||||
"""Register callbacks."""
|
||||
self.async_on_remove(
|
||||
async_dispatcher_connect(
|
||||
|
@ -168,7 +168,7 @@ class EnvisalinkAlarm(EnvisalinkDevice, AlarmControlPanelEntity):
|
|||
state = STATE_ALARM_DISARMED
|
||||
return state
|
||||
|
||||
async def async_alarm_disarm(self, code=None):
|
||||
async def async_alarm_disarm(self, code: str | None = None) -> None:
|
||||
"""Send disarm command."""
|
||||
if code:
|
||||
self.hass.data[DATA_EVL].disarm_partition(str(code), self._partition_number)
|
||||
|
@ -177,7 +177,7 @@ class EnvisalinkAlarm(EnvisalinkDevice, AlarmControlPanelEntity):
|
|||
str(self._code), self._partition_number
|
||||
)
|
||||
|
||||
async def async_alarm_arm_home(self, code=None):
|
||||
async def async_alarm_arm_home(self, code: str | None = None) -> None:
|
||||
"""Send arm home command."""
|
||||
if code:
|
||||
self.hass.data[DATA_EVL].arm_stay_partition(
|
||||
|
@ -188,7 +188,7 @@ class EnvisalinkAlarm(EnvisalinkDevice, AlarmControlPanelEntity):
|
|||
str(self._code), self._partition_number
|
||||
)
|
||||
|
||||
async def async_alarm_arm_away(self, code=None):
|
||||
async def async_alarm_arm_away(self, code: str | None = None) -> None:
|
||||
"""Send arm away command."""
|
||||
if code:
|
||||
self.hass.data[DATA_EVL].arm_away_partition(
|
||||
|
@ -199,11 +199,11 @@ class EnvisalinkAlarm(EnvisalinkDevice, AlarmControlPanelEntity):
|
|||
str(self._code), self._partition_number
|
||||
)
|
||||
|
||||
async def async_alarm_trigger(self, code=None):
|
||||
async def async_alarm_trigger(self, code: str | None = None) -> None:
|
||||
"""Alarm trigger command. Will be used to trigger a panic alarm."""
|
||||
self.hass.data[DATA_EVL].panic_alarm(self._panic_type)
|
||||
|
||||
async def async_alarm_arm_night(self, code=None):
|
||||
async def async_alarm_arm_night(self, code: str | None = None) -> None:
|
||||
"""Send arm night command."""
|
||||
self.hass.data[DATA_EVL].arm_night_partition(
|
||||
str(code) if code else str(self._code), self._partition_number
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
"""Support for the Hive alarm."""
|
||||
from __future__ import annotations
|
||||
|
||||
from datetime import timedelta
|
||||
|
||||
from homeassistant.components.alarm_control_panel import (
|
||||
|
@ -49,19 +51,19 @@ class HiveAlarmControlPanelEntity(HiveEntity, AlarmControlPanelEntity):
|
|||
| AlarmControlPanelEntityFeature.ARM_AWAY
|
||||
)
|
||||
|
||||
async def async_alarm_disarm(self, code=None):
|
||||
async def async_alarm_disarm(self, code: str | None = None) -> None:
|
||||
"""Send disarm command."""
|
||||
await self.hive.alarm.setMode(self.device, "home")
|
||||
|
||||
async def async_alarm_arm_night(self, code=None):
|
||||
async def async_alarm_arm_night(self, code: str | None = None) -> None:
|
||||
"""Send arm night command."""
|
||||
await self.hive.alarm.setMode(self.device, "asleep")
|
||||
|
||||
async def async_alarm_arm_away(self, code=None):
|
||||
async def async_alarm_arm_away(self, code: str | None = None) -> None:
|
||||
"""Send arm away command."""
|
||||
await self.hive.alarm.setMode(self.device, "away")
|
||||
|
||||
async def async_update(self):
|
||||
async def async_update(self) -> None:
|
||||
"""Update all Node data from Hive."""
|
||||
await self.hive.session.updateData(self.device)
|
||||
self.device = await self.hive.alarm.getAlarm(self.device)
|
||||
|
|
|
@ -83,15 +83,15 @@ class HomematicipAlarmControlPanelEntity(AlarmControlPanelEntity):
|
|||
def _security_and_alarm(self) -> SecurityAndAlarmHome:
|
||||
return self._home.get_functionalHome(SecurityAndAlarmHome)
|
||||
|
||||
async def async_alarm_disarm(self, code=None) -> None:
|
||||
async def async_alarm_disarm(self, code: str | None = None) -> None:
|
||||
"""Send disarm command."""
|
||||
await self._home.set_security_zones_activation(False, False)
|
||||
|
||||
async def async_alarm_arm_home(self, code=None) -> None:
|
||||
async def async_alarm_arm_home(self, code: str | None = None) -> None:
|
||||
"""Send arm home command."""
|
||||
await self._home.set_security_zones_activation(False, True)
|
||||
|
||||
async def async_alarm_arm_away(self, code=None) -> None:
|
||||
async def async_alarm_arm_away(self, code: str | None = None) -> None:
|
||||
"""Send arm away command."""
|
||||
await self._home.set_security_zones_activation(True, True)
|
||||
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
"""Interfaces with iAlarm control panels."""
|
||||
from __future__ import annotations
|
||||
|
||||
from homeassistant.components.alarm_control_panel import (
|
||||
AlarmControlPanelEntity,
|
||||
AlarmControlPanelEntityFeature,
|
||||
|
@ -52,14 +54,14 @@ class IAlarmPanel(CoordinatorEntity, AlarmControlPanelEntity):
|
|||
"""Return the state of the device."""
|
||||
return self.coordinator.state
|
||||
|
||||
def alarm_disarm(self, code=None):
|
||||
def alarm_disarm(self, code: str | None = None) -> None:
|
||||
"""Send disarm command."""
|
||||
self.coordinator.ialarm.disarm()
|
||||
|
||||
def alarm_arm_home(self, code=None):
|
||||
def alarm_arm_home(self, code: str | None = None) -> None:
|
||||
"""Send arm home command."""
|
||||
self.coordinator.ialarm.arm_stay()
|
||||
|
||||
def alarm_arm_away(self, code=None):
|
||||
def alarm_arm_away(self, code: str | None = None) -> None:
|
||||
"""Send arm away command."""
|
||||
self.coordinator.ialarm.arm_away()
|
||||
|
|
|
@ -179,25 +179,25 @@ class IFTTTAlarmPanel(AlarmControlPanelEntity):
|
|||
return CodeFormat.NUMBER
|
||||
return CodeFormat.TEXT
|
||||
|
||||
def alarm_disarm(self, code=None):
|
||||
def alarm_disarm(self, code: str | None = None) -> None:
|
||||
"""Send disarm command."""
|
||||
if not self._check_code(code):
|
||||
return
|
||||
self.set_alarm_state(self._event_disarm, STATE_ALARM_DISARMED)
|
||||
|
||||
def alarm_arm_away(self, code=None):
|
||||
def alarm_arm_away(self, code: str | None = None) -> None:
|
||||
"""Send arm away command."""
|
||||
if self._code_arm_required and not self._check_code(code):
|
||||
return
|
||||
self.set_alarm_state(self._event_away, STATE_ALARM_ARMED_AWAY)
|
||||
|
||||
def alarm_arm_home(self, code=None):
|
||||
def alarm_arm_home(self, code: str | None = None) -> None:
|
||||
"""Send arm home command."""
|
||||
if self._code_arm_required and not self._check_code(code):
|
||||
return
|
||||
self.set_alarm_state(self._event_home, STATE_ALARM_ARMED_HOME)
|
||||
|
||||
def alarm_arm_night(self, code=None):
|
||||
def alarm_arm_night(self, code: str | None = None) -> None:
|
||||
"""Send arm night command."""
|
||||
if self._code_arm_required and not self._check_code(code):
|
||||
return
|
||||
|
|
|
@ -69,14 +69,14 @@ class LupusecAlarm(LupusecDevice, AlarmControlPanelEntity):
|
|||
state = None
|
||||
return state
|
||||
|
||||
def alarm_arm_away(self, code=None):
|
||||
def alarm_arm_away(self, code: str | None = None) -> None:
|
||||
"""Send arm away command."""
|
||||
self._device.set_away()
|
||||
|
||||
def alarm_disarm(self, code=None):
|
||||
def alarm_disarm(self, code: str | None = None) -> None:
|
||||
"""Send disarm command."""
|
||||
self._device.set_standby()
|
||||
|
||||
def alarm_arm_home(self, code=None):
|
||||
def alarm_arm_home(self, code: str | None = None) -> None:
|
||||
"""Send arm home command."""
|
||||
self._device.set_home()
|
||||
|
|
|
@ -302,7 +302,7 @@ class ManualAlarm(alarm.AlarmControlPanelEntity, RestoreEntity):
|
|||
"""Whether the code is required for arm actions."""
|
||||
return self._code_arm_required
|
||||
|
||||
def alarm_disarm(self, code=None):
|
||||
def alarm_disarm(self, code: str | None = None) -> None:
|
||||
"""Send disarm command."""
|
||||
if not self._validate_code(code, STATE_ALARM_DISARMED):
|
||||
return
|
||||
|
@ -311,7 +311,7 @@ class ManualAlarm(alarm.AlarmControlPanelEntity, RestoreEntity):
|
|||
self._state_ts = dt_util.utcnow()
|
||||
self.schedule_update_ha_state()
|
||||
|
||||
def alarm_arm_home(self, code=None):
|
||||
def alarm_arm_home(self, code: str | None = None) -> None:
|
||||
"""Send arm home command."""
|
||||
if self._code_arm_required and not self._validate_code(
|
||||
code, STATE_ALARM_ARMED_HOME
|
||||
|
@ -320,7 +320,7 @@ class ManualAlarm(alarm.AlarmControlPanelEntity, RestoreEntity):
|
|||
|
||||
self._update_state(STATE_ALARM_ARMED_HOME)
|
||||
|
||||
def alarm_arm_away(self, code=None):
|
||||
def alarm_arm_away(self, code: str | None = None) -> None:
|
||||
"""Send arm away command."""
|
||||
if self._code_arm_required and not self._validate_code(
|
||||
code, STATE_ALARM_ARMED_AWAY
|
||||
|
@ -329,7 +329,7 @@ class ManualAlarm(alarm.AlarmControlPanelEntity, RestoreEntity):
|
|||
|
||||
self._update_state(STATE_ALARM_ARMED_AWAY)
|
||||
|
||||
def alarm_arm_night(self, code=None):
|
||||
def alarm_arm_night(self, code: str | None = None) -> None:
|
||||
"""Send arm night command."""
|
||||
if self._code_arm_required and not self._validate_code(
|
||||
code, STATE_ALARM_ARMED_NIGHT
|
||||
|
@ -338,7 +338,7 @@ class ManualAlarm(alarm.AlarmControlPanelEntity, RestoreEntity):
|
|||
|
||||
self._update_state(STATE_ALARM_ARMED_NIGHT)
|
||||
|
||||
def alarm_arm_vacation(self, code=None):
|
||||
def alarm_arm_vacation(self, code: str | None = None) -> None:
|
||||
"""Send arm vacation command."""
|
||||
if self._code_arm_required and not self._validate_code(
|
||||
code, STATE_ALARM_ARMED_VACATION
|
||||
|
@ -347,7 +347,7 @@ class ManualAlarm(alarm.AlarmControlPanelEntity, RestoreEntity):
|
|||
|
||||
self._update_state(STATE_ALARM_ARMED_VACATION)
|
||||
|
||||
def alarm_arm_custom_bypass(self, code=None):
|
||||
def alarm_arm_custom_bypass(self, code: str | None = None) -> None:
|
||||
"""Send arm custom bypass command."""
|
||||
if self._code_arm_required and not self._validate_code(
|
||||
code, STATE_ALARM_ARMED_CUSTOM_BYPASS
|
||||
|
@ -356,7 +356,7 @@ class ManualAlarm(alarm.AlarmControlPanelEntity, RestoreEntity):
|
|||
|
||||
self._update_state(STATE_ALARM_ARMED_CUSTOM_BYPASS)
|
||||
|
||||
def alarm_trigger(self, code=None):
|
||||
def alarm_trigger(self, code: str | None = None) -> None:
|
||||
"""
|
||||
Send alarm trigger command.
|
||||
|
||||
|
@ -428,7 +428,7 @@ class ManualAlarm(alarm.AlarmControlPanelEntity, RestoreEntity):
|
|||
"""Update state at a scheduled point in time."""
|
||||
self.async_write_ha_state()
|
||||
|
||||
async def async_added_to_hass(self):
|
||||
async def async_added_to_hass(self) -> None:
|
||||
"""Run when entity about to be added to hass."""
|
||||
await super().async_added_to_hass()
|
||||
if state := await self.async_get_last_state():
|
||||
|
|
|
@ -327,7 +327,7 @@ class ManualMQTTAlarm(alarm.AlarmControlPanelEntity):
|
|||
"""Whether the code is required for arm actions."""
|
||||
return self._code_arm_required
|
||||
|
||||
def alarm_disarm(self, code=None):
|
||||
def alarm_disarm(self, code: str | None = None) -> None:
|
||||
"""Send disarm command."""
|
||||
if not self._validate_code(code, STATE_ALARM_DISARMED):
|
||||
return
|
||||
|
@ -336,7 +336,7 @@ class ManualMQTTAlarm(alarm.AlarmControlPanelEntity):
|
|||
self._state_ts = dt_util.utcnow()
|
||||
self.schedule_update_ha_state()
|
||||
|
||||
def alarm_arm_home(self, code=None):
|
||||
def alarm_arm_home(self, code: str | None = None) -> None:
|
||||
"""Send arm home command."""
|
||||
if self._code_arm_required and not self._validate_code(
|
||||
code, STATE_ALARM_ARMED_HOME
|
||||
|
@ -345,7 +345,7 @@ class ManualMQTTAlarm(alarm.AlarmControlPanelEntity):
|
|||
|
||||
self._update_state(STATE_ALARM_ARMED_HOME)
|
||||
|
||||
def alarm_arm_away(self, code=None):
|
||||
def alarm_arm_away(self, code: str | None = None) -> None:
|
||||
"""Send arm away command."""
|
||||
if self._code_arm_required and not self._validate_code(
|
||||
code, STATE_ALARM_ARMED_AWAY
|
||||
|
@ -354,7 +354,7 @@ class ManualMQTTAlarm(alarm.AlarmControlPanelEntity):
|
|||
|
||||
self._update_state(STATE_ALARM_ARMED_AWAY)
|
||||
|
||||
def alarm_arm_night(self, code=None):
|
||||
def alarm_arm_night(self, code: str | None = None) -> None:
|
||||
"""Send arm night command."""
|
||||
if self._code_arm_required and not self._validate_code(
|
||||
code, STATE_ALARM_ARMED_NIGHT
|
||||
|
@ -363,7 +363,7 @@ class ManualMQTTAlarm(alarm.AlarmControlPanelEntity):
|
|||
|
||||
self._update_state(STATE_ALARM_ARMED_NIGHT)
|
||||
|
||||
def alarm_trigger(self, code=None):
|
||||
def alarm_trigger(self, code: str | None = None) -> None:
|
||||
"""
|
||||
Send alarm trigger command.
|
||||
|
||||
|
@ -426,7 +426,7 @@ class ManualMQTTAlarm(alarm.AlarmControlPanelEntity):
|
|||
ATTR_POST_PENDING_STATE: self._state,
|
||||
}
|
||||
|
||||
async def async_added_to_hass(self):
|
||||
async def async_added_to_hass(self) -> None:
|
||||
"""Subscribe to MQTT events."""
|
||||
async_track_state_change_event(
|
||||
self.hass, [self.entity_id], self._async_state_changed_listener
|
||||
|
|
|
@ -264,7 +264,7 @@ class MqttAlarm(MqttEntity, alarm.AlarmControlPanelEntity):
|
|||
code_required = self._config.get(CONF_CODE_ARM_REQUIRED)
|
||||
return code_required
|
||||
|
||||
async def async_alarm_disarm(self, code=None):
|
||||
async def async_alarm_disarm(self, code: str | None = None) -> None:
|
||||
"""Send disarm command.
|
||||
|
||||
This method is a coroutine.
|
||||
|
@ -275,7 +275,7 @@ class MqttAlarm(MqttEntity, alarm.AlarmControlPanelEntity):
|
|||
payload = self._config[CONF_PAYLOAD_DISARM]
|
||||
await self._publish(code, payload)
|
||||
|
||||
async def async_alarm_arm_home(self, code=None):
|
||||
async def async_alarm_arm_home(self, code: str | None = None) -> None:
|
||||
"""Send arm home command.
|
||||
|
||||
This method is a coroutine.
|
||||
|
@ -286,7 +286,7 @@ class MqttAlarm(MqttEntity, alarm.AlarmControlPanelEntity):
|
|||
action = self._config[CONF_PAYLOAD_ARM_HOME]
|
||||
await self._publish(code, action)
|
||||
|
||||
async def async_alarm_arm_away(self, code=None):
|
||||
async def async_alarm_arm_away(self, code: str | None = None) -> None:
|
||||
"""Send arm away command.
|
||||
|
||||
This method is a coroutine.
|
||||
|
@ -297,7 +297,7 @@ class MqttAlarm(MqttEntity, alarm.AlarmControlPanelEntity):
|
|||
action = self._config[CONF_PAYLOAD_ARM_AWAY]
|
||||
await self._publish(code, action)
|
||||
|
||||
async def async_alarm_arm_night(self, code=None):
|
||||
async def async_alarm_arm_night(self, code: str | None = None) -> None:
|
||||
"""Send arm night command.
|
||||
|
||||
This method is a coroutine.
|
||||
|
@ -308,7 +308,7 @@ class MqttAlarm(MqttEntity, alarm.AlarmControlPanelEntity):
|
|||
action = self._config[CONF_PAYLOAD_ARM_NIGHT]
|
||||
await self._publish(code, action)
|
||||
|
||||
async def async_alarm_arm_vacation(self, code=None):
|
||||
async def async_alarm_arm_vacation(self, code: str | None = None) -> None:
|
||||
"""Send arm vacation command.
|
||||
|
||||
This method is a coroutine.
|
||||
|
@ -319,7 +319,7 @@ class MqttAlarm(MqttEntity, alarm.AlarmControlPanelEntity):
|
|||
action = self._config[CONF_PAYLOAD_ARM_VACATION]
|
||||
await self._publish(code, action)
|
||||
|
||||
async def async_alarm_arm_custom_bypass(self, code=None):
|
||||
async def async_alarm_arm_custom_bypass(self, code: str | None = None) -> None:
|
||||
"""Send arm custom bypass command.
|
||||
|
||||
This method is a coroutine.
|
||||
|
@ -330,7 +330,7 @@ class MqttAlarm(MqttEntity, alarm.AlarmControlPanelEntity):
|
|||
action = self._config[CONF_PAYLOAD_ARM_CUSTOM_BYPASS]
|
||||
await self._publish(code, action)
|
||||
|
||||
async def async_alarm_trigger(self, code=None):
|
||||
async def async_alarm_trigger(self, code: str | None = None) -> None:
|
||||
"""Send trigger command.
|
||||
|
||||
This method is a coroutine.
|
||||
|
|
|
@ -53,7 +53,7 @@ class NessAlarmPanel(alarm.AlarmControlPanelEntity):
|
|||
self._name = name
|
||||
self._state = None
|
||||
|
||||
async def async_added_to_hass(self):
|
||||
async def async_added_to_hass(self) -> None:
|
||||
"""Register callbacks."""
|
||||
self.async_on_remove(
|
||||
async_dispatcher_connect(
|
||||
|
@ -81,19 +81,19 @@ class NessAlarmPanel(alarm.AlarmControlPanelEntity):
|
|||
"""Return the state of the device."""
|
||||
return self._state
|
||||
|
||||
async def async_alarm_disarm(self, code=None):
|
||||
async def async_alarm_disarm(self, code: str | None = None) -> None:
|
||||
"""Send disarm command."""
|
||||
await self._client.disarm(code)
|
||||
|
||||
async def async_alarm_arm_away(self, code=None):
|
||||
async def async_alarm_arm_away(self, code: str | None = None) -> None:
|
||||
"""Send arm away command."""
|
||||
await self._client.arm_away(code)
|
||||
|
||||
async def async_alarm_arm_home(self, code=None):
|
||||
async def async_alarm_arm_home(self, code: str | None = None) -> None:
|
||||
"""Send arm home command."""
|
||||
await self._client.arm_home(code)
|
||||
|
||||
async def async_alarm_trigger(self, code=None):
|
||||
async def async_alarm_trigger(self, code: str | None = None) -> None:
|
||||
"""Send trigger/panic command."""
|
||||
await self._client.panic(code)
|
||||
|
||||
|
|
|
@ -119,7 +119,7 @@ class NX584Alarm(alarm.AlarmControlPanelEntity):
|
|||
"""Return the state of the device."""
|
||||
return self._state
|
||||
|
||||
def update(self):
|
||||
def update(self) -> None:
|
||||
"""Process new events from panel."""
|
||||
try:
|
||||
part = self._alarm.list_partitions()[0]
|
||||
|
@ -157,15 +157,15 @@ class NX584Alarm(alarm.AlarmControlPanelEntity):
|
|||
if flag == "Siren on":
|
||||
self._state = STATE_ALARM_TRIGGERED
|
||||
|
||||
def alarm_disarm(self, code=None):
|
||||
def alarm_disarm(self, code: str | None = None) -> None:
|
||||
"""Send disarm command."""
|
||||
self._alarm.disarm(code)
|
||||
|
||||
def alarm_arm_home(self, code=None):
|
||||
def alarm_arm_home(self, code: str | None = None) -> None:
|
||||
"""Send arm home command."""
|
||||
self._alarm.arm("stay")
|
||||
|
||||
def alarm_arm_away(self, code=None):
|
||||
def alarm_arm_away(self, code: str | None = None) -> None:
|
||||
"""Send arm away command."""
|
||||
self._alarm.arm("exit")
|
||||
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
"""Support for Minut Point."""
|
||||
from __future__ import annotations
|
||||
|
||||
import logging
|
||||
|
||||
from homeassistant.components.alarm_control_panel import (
|
||||
|
@ -58,14 +60,14 @@ class MinutPointAlarmControl(AlarmControlPanelEntity):
|
|||
self._async_unsub_hook_dispatcher_connect = None
|
||||
self._changed_by = None
|
||||
|
||||
async def async_added_to_hass(self):
|
||||
async def async_added_to_hass(self) -> None:
|
||||
"""Call when entity is added to HOme Assistant."""
|
||||
await super().async_added_to_hass()
|
||||
self._async_unsub_hook_dispatcher_connect = async_dispatcher_connect(
|
||||
self.hass, SIGNAL_WEBHOOK, self._webhook_event
|
||||
)
|
||||
|
||||
async def async_will_remove_from_hass(self):
|
||||
async def async_will_remove_from_hass(self) -> None:
|
||||
"""Disconnect dispatcher listener when removed."""
|
||||
await super().async_will_remove_from_hass()
|
||||
if self._async_unsub_hook_dispatcher_connect:
|
||||
|
@ -106,13 +108,13 @@ class MinutPointAlarmControl(AlarmControlPanelEntity):
|
|||
"""Return the user the last change was triggered by."""
|
||||
return self._changed_by
|
||||
|
||||
async def async_alarm_disarm(self, code=None):
|
||||
async def async_alarm_disarm(self, code: str | None = None) -> None:
|
||||
"""Send disarm command."""
|
||||
status = await self._client.async_alarm_disarm(self._home_id)
|
||||
if status:
|
||||
self._home["alarm_status"] = "off"
|
||||
|
||||
async def async_alarm_arm_away(self, code=None):
|
||||
async def async_alarm_arm_away(self, code: str | None = None) -> None:
|
||||
"""Send arm away command."""
|
||||
status = await self._client.async_alarm_arm(self._home_id)
|
||||
if status:
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
"""Support for Risco alarms."""
|
||||
from __future__ import annotations
|
||||
|
||||
import logging
|
||||
|
||||
from homeassistant.components.alarm_control_panel import (
|
||||
|
@ -138,26 +140,26 @@ class RiscoAlarm(AlarmControlPanelEntity, RiscoEntity):
|
|||
"""Validate given code."""
|
||||
return code == self._code
|
||||
|
||||
async def async_alarm_disarm(self, code=None):
|
||||
async def async_alarm_disarm(self, code: str | None = None) -> None:
|
||||
"""Send disarm command."""
|
||||
if self._code_disarm_required and not self._validate_code(code):
|
||||
_LOGGER.warning("Wrong code entered for disarming")
|
||||
return
|
||||
await self._call_alarm_method("disarm")
|
||||
|
||||
async def async_alarm_arm_home(self, code=None):
|
||||
async def async_alarm_arm_home(self, code: str | None = None) -> None:
|
||||
"""Send arm home command."""
|
||||
await self._arm(STATE_ALARM_ARMED_HOME, code)
|
||||
|
||||
async def async_alarm_arm_away(self, code=None):
|
||||
async def async_alarm_arm_away(self, code: str | None = None) -> None:
|
||||
"""Send arm away command."""
|
||||
await self._arm(STATE_ALARM_ARMED_AWAY, code)
|
||||
|
||||
async def async_alarm_arm_night(self, code=None):
|
||||
async def async_alarm_arm_night(self, code: str | None = None) -> None:
|
||||
"""Send arm night command."""
|
||||
await self._arm(STATE_ALARM_ARMED_NIGHT, code)
|
||||
|
||||
async def async_alarm_arm_custom_bypass(self, code=None):
|
||||
async def async_alarm_arm_custom_bypass(self, code: str | None = None) -> None:
|
||||
"""Send arm custom bypass command."""
|
||||
await self._arm(STATE_ALARM_ARMED_CUSTOM_BYPASS, code)
|
||||
|
||||
|
|
|
@ -74,7 +74,7 @@ class SatelIntegraAlarmPanel(alarm.AlarmControlPanelEntity):
|
|||
self._partition_id = partition_id
|
||||
self._satel = controller
|
||||
|
||||
async def async_added_to_hass(self):
|
||||
async def async_added_to_hass(self) -> None:
|
||||
"""Update alarm status and register callbacks for future updates."""
|
||||
_LOGGER.debug("Starts listening for panel messages")
|
||||
self._update_alarm_status()
|
||||
|
@ -149,7 +149,7 @@ class SatelIntegraAlarmPanel(alarm.AlarmControlPanelEntity):
|
|||
"""Return the state of the device."""
|
||||
return self._state
|
||||
|
||||
async def async_alarm_disarm(self, code=None):
|
||||
async def async_alarm_disarm(self, code: str | None = None) -> None:
|
||||
"""Send disarm command."""
|
||||
if not code:
|
||||
_LOGGER.debug("Code was empty or None")
|
||||
|
@ -166,14 +166,14 @@ class SatelIntegraAlarmPanel(alarm.AlarmControlPanelEntity):
|
|||
await asyncio.sleep(1)
|
||||
await self._satel.clear_alarm(code, [self._partition_id])
|
||||
|
||||
async def async_alarm_arm_away(self, code=None):
|
||||
async def async_alarm_arm_away(self, code: str | None = None) -> None:
|
||||
"""Send arm away command."""
|
||||
_LOGGER.debug("Arming away")
|
||||
|
||||
if code:
|
||||
await self._satel.arm(code, [self._partition_id])
|
||||
|
||||
async def async_alarm_arm_home(self, code=None):
|
||||
async def async_alarm_arm_home(self, code: str | None = None) -> None:
|
||||
"""Send arm home command."""
|
||||
_LOGGER.debug("Arming home")
|
||||
|
||||
|
|
|
@ -62,7 +62,7 @@ class SpcAlarm(alarm.AlarmControlPanelEntity):
|
|||
self._area = area
|
||||
self._api = api
|
||||
|
||||
async def async_added_to_hass(self):
|
||||
async def async_added_to_hass(self) -> None:
|
||||
"""Call for adding new entities."""
|
||||
self.async_on_remove(
|
||||
async_dispatcher_connect(
|
||||
|
@ -97,22 +97,22 @@ class SpcAlarm(alarm.AlarmControlPanelEntity):
|
|||
"""Return the state of the device."""
|
||||
return _get_alarm_state(self._area)
|
||||
|
||||
async def async_alarm_disarm(self, code=None):
|
||||
async def async_alarm_disarm(self, code: str | None = None) -> None:
|
||||
"""Send disarm command."""
|
||||
|
||||
await self._api.change_mode(area=self._area, new_mode=AreaMode.UNSET)
|
||||
|
||||
async def async_alarm_arm_home(self, code=None):
|
||||
async def async_alarm_arm_home(self, code: str | None = None) -> None:
|
||||
"""Send arm home command."""
|
||||
|
||||
await self._api.change_mode(area=self._area, new_mode=AreaMode.PART_SET_A)
|
||||
|
||||
async def async_alarm_arm_night(self, code=None):
|
||||
async def async_alarm_arm_night(self, code: str | None = None) -> None:
|
||||
"""Send arm home command."""
|
||||
|
||||
await self._api.change_mode(area=self._area, new_mode=AreaMode.PART_SET_B)
|
||||
|
||||
async def async_alarm_arm_away(self, code=None):
|
||||
async def async_alarm_arm_away(self, code: str | None = None) -> None:
|
||||
"""Send arm away command."""
|
||||
|
||||
await self._api.change_mode(area=self._area, new_mode=AreaMode.FULL_SET)
|
||||
|
|
|
@ -216,7 +216,7 @@ class AlarmControlPanelTemplate(TemplateEntity, AlarmControlPanelEntity):
|
|||
)
|
||||
self._state = None
|
||||
|
||||
async def async_added_to_hass(self):
|
||||
async def async_added_to_hass(self) -> None:
|
||||
"""Register callbacks."""
|
||||
if self._template:
|
||||
self.add_template_attribute(
|
||||
|
@ -239,25 +239,25 @@ class AlarmControlPanelTemplate(TemplateEntity, AlarmControlPanelEntity):
|
|||
if optimistic_set:
|
||||
self.async_write_ha_state()
|
||||
|
||||
async def async_alarm_arm_away(self, code=None):
|
||||
async def async_alarm_arm_away(self, code: str | None = None) -> None:
|
||||
"""Arm the panel to Away."""
|
||||
await self._async_alarm_arm(
|
||||
STATE_ALARM_ARMED_AWAY, script=self._arm_away_script, code=code
|
||||
)
|
||||
|
||||
async def async_alarm_arm_home(self, code=None):
|
||||
async def async_alarm_arm_home(self, code: str | None = None) -> None:
|
||||
"""Arm the panel to Home."""
|
||||
await self._async_alarm_arm(
|
||||
STATE_ALARM_ARMED_HOME, script=self._arm_home_script, code=code
|
||||
)
|
||||
|
||||
async def async_alarm_arm_night(self, code=None):
|
||||
async def async_alarm_arm_night(self, code: str | None = None) -> None:
|
||||
"""Arm the panel to Night."""
|
||||
await self._async_alarm_arm(
|
||||
STATE_ALARM_ARMED_NIGHT, script=self._arm_night_script, code=code
|
||||
)
|
||||
|
||||
async def async_alarm_disarm(self, code=None):
|
||||
async def async_alarm_disarm(self, code: str | None = None) -> None:
|
||||
"""Disarm the panel."""
|
||||
await self._async_alarm_arm(
|
||||
STATE_ALARM_DISARMED, script=self._disarm_script, code=code
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
"""Interfaces with TotalConnect alarm control panels."""
|
||||
from __future__ import annotations
|
||||
|
||||
from total_connect_client import ArmingHelper
|
||||
from total_connect_client.exceptions import BadResultCodeError, UsercodeInvalid
|
||||
|
||||
|
@ -163,7 +165,7 @@ class TotalConnectAlarm(CoordinatorEntity, alarm.AlarmControlPanelEntity):
|
|||
"""Return the state attributes of the device."""
|
||||
return self._extra_state_attributes
|
||||
|
||||
async def async_alarm_disarm(self, code=None):
|
||||
async def async_alarm_disarm(self, code: str | None = None) -> None:
|
||||
"""Send disarm command."""
|
||||
try:
|
||||
await self.hass.async_add_executor_job(self._disarm)
|
||||
|
@ -182,7 +184,7 @@ class TotalConnectAlarm(CoordinatorEntity, alarm.AlarmControlPanelEntity):
|
|||
"""Disarm synchronous."""
|
||||
ArmingHelper(self._partition).disarm()
|
||||
|
||||
async def async_alarm_arm_home(self, code=None):
|
||||
async def async_alarm_arm_home(self, code: str | None = None) -> None:
|
||||
"""Send arm home command."""
|
||||
try:
|
||||
await self.hass.async_add_executor_job(self._arm_home)
|
||||
|
@ -201,7 +203,7 @@ class TotalConnectAlarm(CoordinatorEntity, alarm.AlarmControlPanelEntity):
|
|||
"""Arm home synchronous."""
|
||||
ArmingHelper(self._partition).arm_stay()
|
||||
|
||||
async def async_alarm_arm_away(self, code=None):
|
||||
async def async_alarm_arm_away(self, code: str | None = None) -> None:
|
||||
"""Send arm away command."""
|
||||
try:
|
||||
await self.hass.async_add_executor_job(self._arm_away)
|
||||
|
@ -220,7 +222,7 @@ class TotalConnectAlarm(CoordinatorEntity, alarm.AlarmControlPanelEntity):
|
|||
"""Arm away synchronous."""
|
||||
ArmingHelper(self._partition).arm_away()
|
||||
|
||||
async def async_alarm_arm_night(self, code=None):
|
||||
async def async_alarm_arm_night(self, code: str | None = None) -> None:
|
||||
"""Send arm night command."""
|
||||
try:
|
||||
await self.hass.async_add_executor_job(self._arm_night)
|
||||
|
@ -239,7 +241,7 @@ class TotalConnectAlarm(CoordinatorEntity, alarm.AlarmControlPanelEntity):
|
|||
"""Arm night synchronous."""
|
||||
ArmingHelper(self._partition).arm_stay_night()
|
||||
|
||||
async def async_alarm_arm_home_instant(self, code=None):
|
||||
async def async_alarm_arm_home_instant(self, code: str | None = None) -> None:
|
||||
"""Send arm home instant command."""
|
||||
try:
|
||||
await self.hass.async_add_executor_job(self._arm_home_instant)
|
||||
|
@ -258,7 +260,7 @@ class TotalConnectAlarm(CoordinatorEntity, alarm.AlarmControlPanelEntity):
|
|||
"""Arm home instant synchronous."""
|
||||
ArmingHelper(self._partition).arm_stay_instant()
|
||||
|
||||
async def async_alarm_arm_away_instant(self, code=None):
|
||||
async def async_alarm_arm_away_instant(self, code: str | None = None) -> None:
|
||||
"""Send arm away instant command."""
|
||||
try:
|
||||
await self.hass.async_add_executor_job(self._arm_away_instant)
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
"""Support for Xiomi Gateway alarm control panels."""
|
||||
from __future__ import annotations
|
||||
|
||||
from functools import partial
|
||||
import logging
|
||||
|
||||
|
@ -110,19 +112,19 @@ class XiaomiGatewayAlarm(AlarmControlPanelEntity):
|
|||
except DeviceException as exc:
|
||||
_LOGGER.error(mask_error, exc)
|
||||
|
||||
async def async_alarm_arm_away(self, code=None):
|
||||
async def async_alarm_arm_away(self, code: str | None = None) -> None:
|
||||
"""Turn on."""
|
||||
await self._try_command(
|
||||
"Turning the alarm on failed: %s", self._gateway.alarm.on
|
||||
)
|
||||
|
||||
async def async_alarm_disarm(self, code=None):
|
||||
async def async_alarm_disarm(self, code: str | None = None) -> None:
|
||||
"""Turn off."""
|
||||
await self._try_command(
|
||||
"Turning the alarm off failed: %s", self._gateway.alarm.off
|
||||
)
|
||||
|
||||
async def async_update(self):
|
||||
async def async_update(self) -> None:
|
||||
"""Fetch state from the device."""
|
||||
try:
|
||||
state = await self.hass.async_add_executor_job(self._gateway.alarm.status)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue