From 34d215088fade60286b2bc02705f64dc7bd15814 Mon Sep 17 00:00:00 2001 From: Robert Resch Date: Tue, 3 Oct 2023 07:27:55 +0000 Subject: [PATCH] Remove "none" in favor of optional select in brottsplatskartan --- homeassistant/components/brottsplatskartan/config_flow.py | 7 ++----- homeassistant/components/brottsplatskartan/const.py | 1 - homeassistant/components/brottsplatskartan/strings.json | 7 ------- tests/components/brottsplatskartan/test_config_flow.py | 5 +---- 4 files changed, 3 insertions(+), 17 deletions(-) diff --git a/homeassistant/components/brottsplatskartan/config_flow.py b/homeassistant/components/brottsplatskartan/config_flow.py index 09d6cd960873c6..ac9a764179e769 100644 --- a/homeassistant/components/brottsplatskartan/config_flow.py +++ b/homeassistant/components/brottsplatskartan/config_flow.py @@ -18,11 +18,10 @@ 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 @@ async def async_step_user( 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}" diff --git a/homeassistant/components/brottsplatskartan/const.py b/homeassistant/components/brottsplatskartan/const.py index 8bd08f452f4908..b53a39755a6e88 100644 --- a/homeassistant/components/brottsplatskartan/const.py +++ b/homeassistant/components/brottsplatskartan/const.py @@ -14,7 +14,6 @@ DEFAULT_NAME = "Brottsplatskartan" AREAS = [ - "none", "Blekinge län", "Dalarnas län", "Gotlands län", diff --git a/homeassistant/components/brottsplatskartan/strings.json b/homeassistant/components/brottsplatskartan/strings.json index f10120f7884553..bd8d5ad8dbec36 100644 --- a/homeassistant/components/brottsplatskartan/strings.json +++ b/homeassistant/components/brottsplatskartan/strings.json @@ -15,12 +15,5 @@ } } } - }, - "selector": { - "areas": { - "options": { - "none": "No area" - } - } } } diff --git a/tests/components/brottsplatskartan/test_config_flow.py b/tests/components/brottsplatskartan/test_config_flow.py index efd259fa73cf8a..f27139ad381e9a 100644 --- a/tests/components/brottsplatskartan/test_config_flow.py +++ b/tests/components/brottsplatskartan/test_config_flow.py @@ -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,