Bugfix for overkiz.alarm_control_panel platform exception (#69131)

* Revert changes

* Remove debug statement
pull/69149/head
Mick Vleeshouwer 2022-04-02 12:27:12 -07:00 committed by GitHub
parent 963ed74797
commit 1103c5d101
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 18 additions and 11 deletions

View File

@ -3,7 +3,7 @@ from __future__ import annotations
from collections.abc import Callable from collections.abc import Callable
from dataclasses import dataclass from dataclasses import dataclass
from typing import cast from typing import Any, cast
from pyoverkiz.enums import OverkizCommand, OverkizCommandParam, OverkizState from pyoverkiz.enums import OverkizCommand, OverkizCommandParam, OverkizState
from pyoverkiz.enums.ui import UIWidget from pyoverkiz.enums.ui import UIWidget
@ -55,15 +55,15 @@ class OverkizAlarmDescription(
"""Class to describe an Overkiz alarm control panel.""" """Class to describe an Overkiz alarm control panel."""
alarm_disarm: str | None = None alarm_disarm: str | None = None
alarm_disarm_args: OverkizStateType | list[OverkizStateType] = [] alarm_disarm_args: OverkizStateType | list[OverkizStateType] = None
alarm_arm_home: str | None = None alarm_arm_home: str | None = None
alarm_arm_home_args: OverkizStateType | list[OverkizStateType] = [] alarm_arm_home_args: OverkizStateType | list[OverkizStateType] = None
alarm_arm_night: str | None = None alarm_arm_night: str | None = None
alarm_arm_night_args: OverkizStateType | list[OverkizStateType] = [] alarm_arm_night_args: OverkizStateType | list[OverkizStateType] = None
alarm_arm_away: str | None = None alarm_arm_away: str | None = None
alarm_arm_away_args: OverkizStateType | list[OverkizStateType] = [] alarm_arm_away_args: OverkizStateType | list[OverkizStateType] = None
alarm_trigger: str | None = None alarm_trigger: str | None = None
alarm_trigger_args: OverkizStateType | list[OverkizStateType] = [] alarm_trigger_args: OverkizStateType | list[OverkizStateType] = None
MAP_INTERNAL_STATUS_STATE: dict[str, str] = { MAP_INTERNAL_STATUS_STATE: dict[str, str] = {
@ -266,7 +266,7 @@ class OverkizAlarmControlPanel(OverkizDescriptiveEntity, AlarmControlPanelEntity
async def async_alarm_disarm(self, code: str | None = None) -> None: async def async_alarm_disarm(self, code: str | None = None) -> None:
"""Send disarm command.""" """Send disarm command."""
assert self.entity_description.alarm_disarm assert self.entity_description.alarm_disarm
await self.executor.async_execute_command( await self.async_execute_command(
self.entity_description.alarm_disarm, self.entity_description.alarm_disarm,
self.entity_description.alarm_disarm_args, self.entity_description.alarm_disarm_args,
) )
@ -274,7 +274,7 @@ class OverkizAlarmControlPanel(OverkizDescriptiveEntity, AlarmControlPanelEntity
async def async_alarm_arm_home(self, code: str | None = None) -> None: async def async_alarm_arm_home(self, code: str | None = None) -> None:
"""Send arm home command.""" """Send arm home command."""
assert self.entity_description.alarm_arm_home assert self.entity_description.alarm_arm_home
await self.executor.async_execute_command( await self.async_execute_command(
self.entity_description.alarm_arm_home, self.entity_description.alarm_arm_home,
self.entity_description.alarm_arm_home_args, self.entity_description.alarm_arm_home_args,
) )
@ -282,7 +282,7 @@ class OverkizAlarmControlPanel(OverkizDescriptiveEntity, AlarmControlPanelEntity
async def async_alarm_arm_night(self, code: str | None = None) -> None: async def async_alarm_arm_night(self, code: str | None = None) -> None:
"""Send arm night command.""" """Send arm night command."""
assert self.entity_description.alarm_arm_night assert self.entity_description.alarm_arm_night
await self.executor.async_execute_command( await self.async_execute_command(
self.entity_description.alarm_arm_night, self.entity_description.alarm_arm_night,
self.entity_description.alarm_arm_night_args, self.entity_description.alarm_arm_night_args,
) )
@ -290,7 +290,7 @@ class OverkizAlarmControlPanel(OverkizDescriptiveEntity, AlarmControlPanelEntity
async def async_alarm_arm_away(self, code: str | None = None) -> None: async def async_alarm_arm_away(self, code: str | None = None) -> None:
"""Send arm away command.""" """Send arm away command."""
assert self.entity_description.alarm_arm_away assert self.entity_description.alarm_arm_away
await self.executor.async_execute_command( await self.async_execute_command(
self.entity_description.alarm_arm_away, self.entity_description.alarm_arm_away,
self.entity_description.alarm_arm_away_args, self.entity_description.alarm_arm_away_args,
) )
@ -298,7 +298,14 @@ class OverkizAlarmControlPanel(OverkizDescriptiveEntity, AlarmControlPanelEntity
async def async_alarm_trigger(self, code: str | None = None) -> None: async def async_alarm_trigger(self, code: str | None = None) -> None:
"""Send alarm trigger command.""" """Send alarm trigger command."""
assert self.entity_description.alarm_trigger assert self.entity_description.alarm_trigger
await self.executor.async_execute_command( await self.async_execute_command(
self.entity_description.alarm_trigger, self.entity_description.alarm_trigger,
self.entity_description.alarm_trigger_args, self.entity_description.alarm_trigger_args,
) )
async def async_execute_command(self, command_name: str, args: Any) -> None:
"""Execute device command in async context."""
if args:
await self.executor.async_execute_command(command_name, args)
else:
await self.executor.async_execute_command(command_name)