From 7dec23d58bbd432d76b63aba3ce1699699b126ba Mon Sep 17 00:00:00 2001 From: Erik Montnemery Date: Thu, 6 May 2021 06:25:28 +0200 Subject: [PATCH] Improve translation strings for MQTT config and option flows (#50018) Co-authored-by: Franck Nijhof --- homeassistant/components/mqtt/config_flow.py | 7 ++----- homeassistant/components/mqtt/strings.json | 4 +++- homeassistant/components/mqtt/translations/en.json | 10 ++++++---- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/homeassistant/components/mqtt/config_flow.py b/homeassistant/components/mqtt/config_flow.py index baa5b1cc29a..c6af0cc08b5 100644 --- a/homeassistant/components/mqtt/config_flow.py +++ b/homeassistant/components/mqtt/config_flow.py @@ -65,6 +65,7 @@ class FlowHandler(config_entries.ConfigFlow, domain=DOMAIN): ) if can_connect: + user_input[CONF_DISCOVERY] = DEFAULT_DISCOVERY return self.async_create_entry( title=user_input[CONF_BROKER], data=user_input ) @@ -76,7 +77,6 @@ class FlowHandler(config_entries.ConfigFlow, domain=DOMAIN): fields[vol.Required(CONF_PORT, default=1883)] = vol.Coerce(int) fields[vol.Optional(CONF_USERNAME)] = str fields[vol.Optional(CONF_PASSWORD)] = str - fields[vol.Optional(CONF_DISCOVERY, default=DEFAULT_DISCOVERY)] = bool return self.async_show_form( step_id="broker", data_schema=vol.Schema(fields), errors=errors @@ -126,7 +126,7 @@ class FlowHandler(config_entries.ConfigFlow, domain=DOMAIN): CONF_USERNAME: data.get(CONF_USERNAME), CONF_PASSWORD: data.get(CONF_PASSWORD), CONF_PROTOCOL: data.get(CONF_PROTOCOL), - CONF_DISCOVERY: user_input[CONF_DISCOVERY], + CONF_DISCOVERY: DEFAULT_DISCOVERY, }, ) @@ -135,9 +135,6 @@ class FlowHandler(config_entries.ConfigFlow, domain=DOMAIN): return self.async_show_form( step_id="hassio_confirm", description_placeholders={"addon": self._hassio_discovery["addon"]}, - data_schema=vol.Schema( - {vol.Optional(CONF_DISCOVERY, default=DEFAULT_DISCOVERY): bool} - ), errors=errors, ) diff --git a/homeassistant/components/mqtt/strings.json b/homeassistant/components/mqtt/strings.json index 2edbc86eb8c..9de9075f19d 100644 --- a/homeassistant/components/mqtt/strings.json +++ b/homeassistant/components/mqtt/strings.json @@ -51,6 +51,7 @@ "options": { "step": { "broker": { + "title": "Broker options", "description": "Please enter the connection information of your MQTT broker.", "data": { "broker": "Broker", @@ -60,7 +61,8 @@ } }, "options": { - "description": "Please select MQTT options.", + "title": "MQTT options", + "description": "Discovery - If discovery is enabled (recommended), Home Assistant will automatically discover devices and entities which publish their configuration on the MQTT broker. If discovery is disabled, all configuration must be done manually.\nBirth message - The birth message will be sent each time Home Assistant (re)connects to the MQTT broker.\nWill message - The will message will be sent each time Home Assistant loses its connection to the broker, both in case of a clean (e.g. Home Assistant shutting down) and in case of an unclean (e.g. Home Assistant crashing or losing its network connection) disconnect.", "data": { "discovery": "Enable discovery", "birth_enable": "Enable birth message", diff --git a/homeassistant/components/mqtt/translations/en.json b/homeassistant/components/mqtt/translations/en.json index c8d24b78fb7..ddd2a38c3b6 100644 --- a/homeassistant/components/mqtt/translations/en.json +++ b/homeassistant/components/mqtt/translations/en.json @@ -15,7 +15,7 @@ "port": "Port", "username": "Username" }, - "description": "Please enter the connection information of your MQTT broker." + "description": "Please enter the connection information of your MQTT broker and select if MQTT discovery should be enabled (recommended). If discovery is enabled, Home Assistant will automatically discover devices and entities which publish their configuration on the MQTT broker. If discovery is disabled, all configuration must be done manually." }, "hassio_confirm": { "data": { @@ -62,7 +62,8 @@ "port": "Port", "username": "Username" }, - "description": "Please enter the connection information of your MQTT broker." + "description": "Please enter the connection information of your MQTT broker.", + "title": "Broker options" }, "options": { "data": { @@ -78,8 +79,9 @@ "will_retain": "Will message retain", "will_topic": "Will message topic" }, - "description": "Please select MQTT options." + "description": "### Discovery \n If discovery is enabled (recommended), Home Assistant will automatically discover devices and entities which publish their configuration on the MQTT broker. If discovery is disabled, all configuration must be done manually. \n ### Birth message\n The birth message will be sent each time Home Assistant (re)connects to the MQTT broker. \n ### Will message \n The will message will be sent each time Home Assistant loses its connection to the broker, both in case of a clean (e.g. Home Assistant shutting down) and in case of an unclean (e.g. Home Assistant crashing or losing its network connection) disconnect.", + "title": "MQTT options" } } } -} \ No newline at end of file +}