Skip to content

Commit

Permalink
Add translation to communication exceptions in MotionMount (#126043)
Browse files Browse the repository at this point in the history
Add translation to communication exceptions
  • Loading branch information
RJPoelstra authored Sep 16, 2024
1 parent e85ab06 commit 3ba39d5
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
10 changes: 8 additions & 2 deletions homeassistant/components/motionmount/number.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,10 @@ async def async_set_native_value(self, value: float) -> None:
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):
Expand All @@ -78,4 +81,7 @@ async def async_set_native_value(self, value: float) -> None:
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
5 changes: 4 additions & 1 deletion homeassistant/components/motionmount/select.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ async def async_select_option(self, option: str) -> None:
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
5 changes: 5 additions & 0 deletions homeassistant/components/motionmount/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,10 @@
}
}
}
},
"exceptions": {
"failed_communication": {
"message": "Failed to communicate with MotionMount"
}
}
}

0 comments on commit 3ba39d5

Please sign in to comment.