Add error translations to Yale Smart Living (#105678)

This commit is contained in:
G Johansson 2023-12-13 19:41:31 +01:00 committed by GitHub
parent 65514fbd73
commit 08b6d2af5e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 36 additions and 4 deletions

View File

@ -83,7 +83,13 @@ class YaleAlarmDevice(YaleAlarmEntity, AlarmControlPanelEntity):
except YALE_ALL_ERRORS as error:
raise HomeAssistantError(
f"Could not set alarm for {self.coordinator.entry.data[CONF_NAME]}:"
f" {error}"
f" {error}",
translation_domain=DOMAIN,
translation_key="set_alarm",
translation_placeholders={
"name": self.coordinator.entry.data[CONF_NAME],
"error": str(error),
},
) from error
if alarm_state:
@ -91,7 +97,9 @@ class YaleAlarmDevice(YaleAlarmEntity, AlarmControlPanelEntity):
self.async_write_ha_state()
return
raise HomeAssistantError(
"Could not change alarm check system ready for arming."
"Could not change alarm, check system ready for arming",
translation_domain=DOMAIN,
translation_key="could_not_change_alarm",
)
@property

View File

@ -79,14 +79,24 @@ class YaleDoorlock(YaleEntity, LockEntity):
)
except YALE_ALL_ERRORS as error:
raise HomeAssistantError(
f"Could not set lock for {self.lock_name}: {error}"
f"Could not set lock for {self.lock_name}: {error}",
translation_domain=DOMAIN,
translation_key="set_lock",
translation_placeholders={
"name": self.lock_name,
"error": str(error),
},
) from error
if lock_state:
self.coordinator.data["lock_map"][self._attr_unique_id] = command
self.async_write_ha_state()
return
raise HomeAssistantError("Could not set lock, check system ready for lock.")
raise HomeAssistantError(
"Could not set lock, check system ready for lock",
translation_domain=DOMAIN,
translation_key="could_not_change_lock",
)
@property
def is_locked(self) -> bool | None:

View File

@ -56,5 +56,19 @@
"name": "Panic button"
}
}
},
"exceptions": {
"set_alarm": {
"message": "Could not set alarm for {name}: {error}"
},
"could_not_change_alarm": {
"message": "Could not change alarm, check system ready for arming"
},
"set_lock": {
"message": "Could not set lock for {name}: {error}"
},
"could_not_change_lock": {
"message": "Could not set lock, check system ready for lock"
}
}
}