Handle exceptions in panic button for Yale Smart Alarm (#116515)
* Handle exceptions in panic button for Yale Smart Alarm * Change key
This commit is contained in:
parent
ffa8265365
commit
ebd1efa53b
2 changed files with 18 additions and 3 deletions
|
@ -6,9 +6,11 @@ from typing import TYPE_CHECKING
|
|||
|
||||
from homeassistant.components.button import ButtonEntity, ButtonEntityDescription
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.exceptions import HomeAssistantError
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
|
||||
from . import YaleConfigEntry
|
||||
from .const import DOMAIN, YALE_ALL_ERRORS
|
||||
from .coordinator import YaleDataUpdateCoordinator
|
||||
from .entity import YaleAlarmEntity
|
||||
|
||||
|
@ -54,6 +56,16 @@ class YalePanicButton(YaleAlarmEntity, ButtonEntity):
|
|||
if TYPE_CHECKING:
|
||||
assert self.coordinator.yale, "Connection to API is missing"
|
||||
|
||||
await self.hass.async_add_executor_job(
|
||||
self.coordinator.yale.trigger_panic_button
|
||||
)
|
||||
try:
|
||||
await self.hass.async_add_executor_job(
|
||||
self.coordinator.yale.trigger_panic_button
|
||||
)
|
||||
except YALE_ALL_ERRORS as error:
|
||||
raise HomeAssistantError(
|
||||
translation_domain=DOMAIN,
|
||||
translation_key="could_not_trigger_panic",
|
||||
translation_placeholders={
|
||||
"entity_id": self.entity_id,
|
||||
"error": str(error),
|
||||
},
|
||||
) from error
|
||||
|
|
|
@ -69,6 +69,9 @@
|
|||
},
|
||||
"could_not_change_lock": {
|
||||
"message": "Could not set lock, check system ready for lock"
|
||||
},
|
||||
"could_not_trigger_panic": {
|
||||
"message": "Could not trigger panic button for entity id {entity_id}: {error}"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue