Remove "none" in favor of optional select in brottsplatskartan (#101311)

pull/101841/head
Robert Resch 2023-10-11 17:52:18 +02:00 committed by GitHub
parent dfea1c2b7c
commit 6c4ac71218
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 3 additions and 17 deletions

View File

@ -18,11 +18,10 @@ DATA_SCHEMA = vol.Schema(
vol.Optional(CONF_LOCATION): selector.LocationSelector(
selector.LocationSelectorConfig(radius=False, icon="")
),
vol.Optional(CONF_AREA, default="none"): selector.SelectSelector(
vol.Optional(CONF_AREA): selector.SelectSelector(
selector.SelectSelectorConfig(
options=AREAS,
mode=selector.SelectSelectorMode.DROPDOWN,
translation_key="areas",
)
),
}
@ -43,9 +42,7 @@ class BPKConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
if user_input is not None:
latitude: float | None = None
longitude: float | None = None
area: str | None = (
user_input[CONF_AREA] if user_input[CONF_AREA] != "none" else None
)
area: str | None = user_input.get(CONF_AREA)
if area:
name = f"{DEFAULT_NAME} {area}"

View File

@ -14,7 +14,6 @@ CONF_APP_ID = "app_id"
DEFAULT_NAME = "Brottsplatskartan"
AREAS = [
"none",
"Blekinge län",
"Dalarnas län",
"Gotlands län",

View File

@ -15,12 +15,5 @@
}
}
}
},
"selector": {
"areas": {
"options": {
"none": "No area"
}
}
}
}

View File

@ -23,9 +23,7 @@ async def test_form(hass: HomeAssistant) -> None:
result2 = await hass.config_entries.flow.async_configure(
result["flow_id"],
{
CONF_AREA: "none",
},
{},
)
await hass.async_block_till_done()
@ -51,7 +49,6 @@ async def test_form_location(hass: HomeAssistant) -> None:
result2 = await hass.config_entries.flow.async_configure(
result["flow_id"],
{
CONF_AREA: "none",
CONF_LOCATION: {
CONF_LATITUDE: 59.32,
CONF_LONGITUDE: 18.06,