Use common strings in luftdaten config flow (#42376)
This commit is contained in:
parent
e6400fc11b
commit
cbf6086c30
3 changed files with 5 additions and 5 deletions
|
@ -69,7 +69,7 @@ class LuftDatenFlowHandler(config_entries.ConfigFlow):
|
|||
sensor_id = user_input[CONF_SENSOR_ID]
|
||||
|
||||
if sensor_id in configured_sensors(self.hass):
|
||||
return self._show_form({CONF_SENSOR_ID: "sensor_exists"})
|
||||
return self._show_form({CONF_SENSOR_ID: "already_configured"})
|
||||
|
||||
session = aiohttp_client.async_get_clientsession(self.hass)
|
||||
luftdaten = Luftdaten(user_input[CONF_SENSOR_ID], self.hass.loop, session)
|
||||
|
@ -77,7 +77,7 @@ class LuftDatenFlowHandler(config_entries.ConfigFlow):
|
|||
await luftdaten.get_data()
|
||||
valid = await luftdaten.validate_sensor()
|
||||
except LuftdatenConnectionError:
|
||||
return self._show_form({CONF_SENSOR_ID: "communication_error"})
|
||||
return self._show_form({CONF_SENSOR_ID: "cannot_connect"})
|
||||
|
||||
if not valid:
|
||||
return self._show_form({CONF_SENSOR_ID: "invalid_sensor"})
|
||||
|
|
|
@ -10,9 +10,9 @@
|
|||
}
|
||||
},
|
||||
"error": {
|
||||
"sensor_exists": "Sensor already registered",
|
||||
"already_configured": "[%key:common::config_flow::abort::already_configured_service%]",
|
||||
"invalid_sensor": "Sensor not available or invalid",
|
||||
"communication_error": "Unable to communicate with the Luftdaten API"
|
||||
"cannot_connect": "[%key:common::config_flow::error::cannot_connect%]"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ async def test_duplicate_error(hass):
|
|||
flow.hass = hass
|
||||
|
||||
result = await flow.async_step_user(user_input=conf)
|
||||
assert result["errors"] == {CONF_SENSOR_ID: "sensor_exists"}
|
||||
assert result["errors"] == {CONF_SENSOR_ID: "already_configured"}
|
||||
|
||||
|
||||
async def test_communication_error(hass):
|
||||
|
|
Loading…
Add table
Reference in a new issue