mirror of
https://github.com/home-assistant/core.git
synced 2025-07-17 10:17:09 +00:00
Add final translations to mqtt exceptions (#131933)
This commit is contained in:
parent
37972ec88e
commit
47aebabc51
@ -776,7 +776,11 @@ class MQTT:
|
||||
else:
|
||||
del self._wildcard_subscriptions[subscription]
|
||||
except (KeyError, ValueError) as exc:
|
||||
raise HomeAssistantError("Can't remove subscription twice") from exc
|
||||
raise HomeAssistantError(
|
||||
translation_domain=DOMAIN,
|
||||
translation_key="mqtt_not_setup_cannot_unsubscribe_twice",
|
||||
translation_placeholders={"topic": topic},
|
||||
) from exc
|
||||
|
||||
@callback
|
||||
def _async_queue_subscriptions(
|
||||
@ -822,7 +826,11 @@ class MQTT:
|
||||
) -> Callable[[], None]:
|
||||
"""Set up a subscription to a topic with the provided qos."""
|
||||
if not isinstance(topic, str):
|
||||
raise HomeAssistantError("Topic needs to be a string!")
|
||||
raise HomeAssistantError(
|
||||
translation_domain=DOMAIN,
|
||||
translation_key="mqtt_topic_not_a_string",
|
||||
translation_placeholders={"topic": topic},
|
||||
)
|
||||
|
||||
if job_type is None:
|
||||
job_type = get_hassjob_callable_job_type(msg_callback)
|
||||
@ -1213,7 +1221,11 @@ class MQTT:
|
||||
import paho.mqtt.client as mqtt
|
||||
|
||||
raise HomeAssistantError(
|
||||
f"Error talking to MQTT: {mqtt.error_string(result_code)}"
|
||||
translation_domain=DOMAIN,
|
||||
translation_key="mqtt_broker_error",
|
||||
translation_placeholders={
|
||||
"error_message": mqtt.error_string(result_code)
|
||||
},
|
||||
)
|
||||
|
||||
# Create the mid event if not created, either _mqtt_handle_mid or
|
||||
|
@ -331,7 +331,9 @@ class FlowHandler(ConfigFlow, domain=DOMAIN):
|
||||
break
|
||||
else:
|
||||
raise AddonError(
|
||||
f"Failed to correctly start {addon_manager.addon_name} add-on"
|
||||
translation_domain=DOMAIN,
|
||||
translation_key="addon_start_failed",
|
||||
translation_placeholders={"addon": addon_manager.addon_name},
|
||||
)
|
||||
|
||||
async def async_step_user(
|
||||
|
@ -148,7 +148,10 @@ class Trigger:
|
||||
def async_remove() -> None:
|
||||
"""Remove trigger."""
|
||||
if instance not in self.trigger_instances:
|
||||
raise HomeAssistantError("Can't remove trigger twice")
|
||||
raise HomeAssistantError(
|
||||
translation_domain=DOMAIN,
|
||||
translation_key="mqtt_trigger_cannot_remove_twice",
|
||||
)
|
||||
|
||||
if instance.remove:
|
||||
instance.remove()
|
||||
|
@ -289,6 +289,9 @@
|
||||
}
|
||||
},
|
||||
"exceptions": {
|
||||
"addon_start_failed": {
|
||||
"message": "Failed to correctly start {addon} add-on."
|
||||
},
|
||||
"command_template_error": {
|
||||
"message": "Parsing template `{command_template}` for entity `{entity_id}` failed with error: {error}."
|
||||
},
|
||||
@ -298,11 +301,23 @@
|
||||
"invalid_publish_topic": {
|
||||
"message": "Unable to publish: topic template `{topic_template}` produced an invalid topic `{topic}` after rendering ({error})"
|
||||
},
|
||||
"mqtt_broker_error": {
|
||||
"message": "Error talking to MQTT: {error_message}."
|
||||
},
|
||||
"mqtt_not_setup_cannot_subscribe": {
|
||||
"message": "Cannot subscribe to topic \"{topic}\", make sure MQTT is set up correctly."
|
||||
},
|
||||
"mqtt_not_setup_cannot_publish": {
|
||||
"message": "Cannot publish to topic \"{topic}\", make sure MQTT is set up correctly."
|
||||
},
|
||||
"mqtt_not_setup_cannot_unsubscribe_twice": {
|
||||
"message": "Cannot unsubscribe topic \"{topic}\" twice."
|
||||
},
|
||||
"mqtt_topic_not_a_string": {
|
||||
"message": "Topic needs to be a string! Got: {topic}."
|
||||
},
|
||||
"mqtt_trigger_cannot_remove_twice": {
|
||||
"message": "Can't remove trigger twice."
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user