mirror of
https://github.com/home-assistant/core.git
synced 2025-07-17 10:17:09 +00:00
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
@ -6,9 +6,11 @@ from typing import TYPE_CHECKING
|
|||||||
|
|
||||||
from homeassistant.components.button import ButtonEntity, ButtonEntityDescription
|
from homeassistant.components.button import ButtonEntity, ButtonEntityDescription
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
|
from homeassistant.exceptions import HomeAssistantError
|
||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
|
|
||||||
from . import YaleConfigEntry
|
from . import YaleConfigEntry
|
||||||
|
from .const import DOMAIN, YALE_ALL_ERRORS
|
||||||
from .coordinator import YaleDataUpdateCoordinator
|
from .coordinator import YaleDataUpdateCoordinator
|
||||||
from .entity import YaleAlarmEntity
|
from .entity import YaleAlarmEntity
|
||||||
|
|
||||||
@ -54,6 +56,16 @@ class YalePanicButton(YaleAlarmEntity, ButtonEntity):
|
|||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
assert self.coordinator.yale, "Connection to API is missing"
|
assert self.coordinator.yale, "Connection to API is missing"
|
||||||
|
|
||||||
await self.hass.async_add_executor_job(
|
try:
|
||||||
self.coordinator.yale.trigger_panic_button
|
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": {
|
"could_not_change_lock": {
|
||||||
"message": "Could not set lock, check system ready for 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…
x
Reference in New Issue
Block a user