Hive Add ability to trigger the alarm (#76985)

* Add ability to trigger the alarm

* Add mapping for sos state when triggered manually

* Update homeassistant/components/hive/alarm_control_panel.py

Co-authored-by: Erik Montnemery <erik@montnemery.com>

* Update homeassistant/components/hive/alarm_control_panel.py

Co-authored-by: Erik Montnemery <erik@montnemery.com>

* Fix linter issues

Co-authored-by: Erik Montnemery <erik@montnemery.com>
This commit is contained in:
Khole 2022-08-22 08:20:12 +01:00 committed by GitHub
parent ed60611b07
commit 1940d9a377
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -27,6 +27,7 @@ HIVETOHA = {
"home": STATE_ALARM_DISARMED, "home": STATE_ALARM_DISARMED,
"asleep": STATE_ALARM_ARMED_NIGHT, "asleep": STATE_ALARM_ARMED_NIGHT,
"away": STATE_ALARM_ARMED_AWAY, "away": STATE_ALARM_ARMED_AWAY,
"sos": STATE_ALARM_TRIGGERED,
} }
@ -49,6 +50,7 @@ class HiveAlarmControlPanelEntity(HiveEntity, AlarmControlPanelEntity):
_attr_supported_features = ( _attr_supported_features = (
AlarmControlPanelEntityFeature.ARM_NIGHT AlarmControlPanelEntityFeature.ARM_NIGHT
| AlarmControlPanelEntityFeature.ARM_AWAY | AlarmControlPanelEntityFeature.ARM_AWAY
| AlarmControlPanelEntityFeature.TRIGGER
) )
async def async_alarm_disarm(self, code: str | None = None) -> None: async def async_alarm_disarm(self, code: str | None = None) -> None:
@ -63,6 +65,10 @@ class HiveAlarmControlPanelEntity(HiveEntity, AlarmControlPanelEntity):
"""Send arm away command.""" """Send arm away command."""
await self.hive.alarm.setMode(self.device, "away") await self.hive.alarm.setMode(self.device, "away")
async def async_alarm_trigger(self, code=None) -> None:
"""Send alarm trigger command."""
await self.hive.alarm.setMode(self.device, "sos")
async def async_update(self) -> None: async def async_update(self) -> None:
"""Update all Node data from Hive.""" """Update all Node data from Hive."""
await self.hive.session.updateData(self.device) await self.hive.session.updateData(self.device)