From 3ba39d515883c1e3120c7d5ab7eb4a5f1f0a56ad Mon Sep 17 00:00:00 2001 From: RJPoelstra <36924801+RJPoelstra@users.noreply.github.com> Date: Mon, 16 Sep 2024 14:43:37 +0200 Subject: [PATCH] Add translation to communication exceptions in MotionMount (#126043) Add translation to communication exceptions --- homeassistant/components/motionmount/number.py | 10 ++++++++-- homeassistant/components/motionmount/select.py | 5 ++++- homeassistant/components/motionmount/strings.json | 5 +++++ 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/homeassistant/components/motionmount/number.py b/homeassistant/components/motionmount/number.py index 25370ec51d8..b42c04a6588 100644 --- a/homeassistant/components/motionmount/number.py +++ b/homeassistant/components/motionmount/number.py @@ -52,7 +52,10 @@ class MotionMountExtension(MotionMountEntity, NumberEntity): try: await self.mm.set_extension(int(value)) except (TimeoutError, socket.gaierror) as ex: - raise HomeAssistantError("Failed to communicate with MotionMount") from ex + raise HomeAssistantError( + translation_domain=DOMAIN, + translation_key="failed_communication", + ) from ex class MotionMountTurn(MotionMountEntity, NumberEntity): @@ -78,4 +81,7 @@ class MotionMountTurn(MotionMountEntity, NumberEntity): try: await self.mm.set_turn(int(value * -1)) except (TimeoutError, socket.gaierror) as ex: - raise HomeAssistantError("Failed to communicate with MotionMount") from ex + raise HomeAssistantError( + translation_domain=DOMAIN, + translation_key="failed_communication", + ) from ex diff --git a/homeassistant/components/motionmount/select.py b/homeassistant/components/motionmount/select.py index 9bca6578bcc..9b43d901a21 100644 --- a/homeassistant/components/motionmount/select.py +++ b/homeassistant/components/motionmount/select.py @@ -91,6 +91,9 @@ class MotionMountPresets(MotionMountEntity, SelectEntity): try: await self.mm.go_to_preset(index) except (TimeoutError, socket.gaierror) as ex: - raise HomeAssistantError("Failed to communicate with MotionMount") from ex + raise HomeAssistantError( + translation_domain=DOMAIN, + translation_key="failed_communication", + ) from ex else: self._attr_current_option = option diff --git a/homeassistant/components/motionmount/strings.json b/homeassistant/components/motionmount/strings.json index 39f7c53db35..bd28156607c 100644 --- a/homeassistant/components/motionmount/strings.json +++ b/homeassistant/components/motionmount/strings.json @@ -56,5 +56,10 @@ } } } + }, + "exceptions": { + "failed_communication": { + "message": "Failed to communicate with MotionMount" + } } }