1 """Support for Verisure alarm control panels."""
3 from __future__
import annotations
8 AlarmControlPanelEntity,
9 AlarmControlPanelEntityFeature,
10 AlarmControlPanelState,
19 from .const
import ALARM_STATE_TO_HA, CONF_GIID, DOMAIN, LOGGER
20 from .coordinator
import VerisureDataUpdateCoordinator
26 async_add_entities: AddEntitiesCallback,
28 """Set up Verisure alarm control panel from a config entry."""
33 CoordinatorEntity[VerisureDataUpdateCoordinator], AlarmControlPanelEntity
35 """Representation of a Verisure alarm status."""
37 _attr_code_format = CodeFormat.NUMBER
38 _attr_has_entity_name =
True
40 _attr_supported_features = (
41 AlarmControlPanelEntityFeature.ARM_HOME
42 | AlarmControlPanelEntityFeature.ARM_AWAY
47 """Return device information about this entity."""
49 name=
"Verisure Alarm",
50 manufacturer=
"Verisure",
52 identifiers={(DOMAIN, self.coordinator.entry.data[CONF_GIID])},
53 configuration_url=
"https://mypages.verisure.com",
58 """Return the unique ID for this entity."""
59 return self.coordinator.entry.data[CONF_GIID]
62 self, state: str, command_data: dict[str, str | dict[str, str]]
64 """Send set arm state command."""
65 arm_state = await self.
hasshasshass.async_add_executor_job(
66 self.coordinator.verisure.request, command_data
68 LOGGER.debug(
"Verisure set arm state %s", state)
71 await asyncio.sleep(0.5)
72 transaction = await self.
hasshasshass.async_add_executor_job(
73 self.coordinator.verisure.request,
74 self.coordinator.verisure.poll_arm_state(
75 list(arm_state[
"data"].values())[0], state
79 transaction.get(
"data", {})
80 .
get(
"installation", {})
81 .
get(
"armStateChangePollResult", {})
88 """Send disarm command."""
92 "DISARMED", self.coordinator.verisure.disarm(code)
96 """Send arm home command."""
100 "ARMED_HOME", self.coordinator.verisure.arm_home(code)
104 """Send arm away command."""
108 "ARMED_AWAY", self.coordinator.verisure.arm_away(code)
113 """Handle updated data from the coordinator."""
115 self.coordinator.data[
"alarm"][
"statusType"]
121 """When entity is added to hass."""
None async_alarm_arm_away(self, str|None code=None)
DeviceInfo device_info(self)
None async_alarm_disarm(self, str|None code=None)
None async_alarm_arm_home(self, str|None code=None)
None _handle_coordinator_update(self)
None _async_set_arm_state(self, str state, dict[str, str|dict[str, str]] command_data)
None async_added_to_hass(self)
None async_write_ha_state(self)
web.Response get(self, web.Request request, str config_key)
None async_setup_entry(HomeAssistant hass, ConfigEntry entry, AddEntitiesCallback async_add_entities)