From a2d707442a2101656a1969956c9b1c008c0c4f81 Mon Sep 17 00:00:00 2001 From: karwosts <32912880+karwosts@users.noreply.github.com> Date: Sun, 28 Jan 2024 08:13:00 -0500 Subject: [PATCH] Fix error when passing a whole number to location selector (#108952) * Fix error when passing an integer to location selector * fix tests * more fix tests * don't mutate original dict * remove string testcase --- homeassistant/helpers/selector.py | 6 +++--- tests/helpers/test_selector.py | 6 +++++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/homeassistant/helpers/selector.py b/homeassistant/helpers/selector.py index 9c4266583e8..52e48724639 100644 --- a/homeassistant/helpers/selector.py +++ b/homeassistant/helpers/selector.py @@ -879,9 +879,9 @@ class LocationSelector(Selector[LocationSelectorConfig]): ) DATA_SCHEMA = vol.Schema( { - vol.Required("latitude"): float, - vol.Required("longitude"): float, - vol.Optional("radius"): float, + vol.Required("latitude"): vol.Coerce(float), + vol.Required("longitude"): vol.Coerce(float), + vol.Optional("radius"): vol.Coerce(float), } ) diff --git a/tests/helpers/test_selector.py b/tests/helpers/test_selector.py index e925b425f96..633673cac98 100644 --- a/tests/helpers/test_selector.py +++ b/tests/helpers/test_selector.py @@ -858,6 +858,11 @@ def test_language_selector_schema(schema, valid_selections, invalid_selections) "longitude": 2.0, "radius": 3.0, }, + { + "latitude": 1, + "longitude": 2, + "radius": 3, + }, ), ( None, @@ -865,7 +870,6 @@ def test_language_selector_schema(schema, valid_selections, invalid_selections) {}, {"latitude": 1.0}, {"longitude": 1.0}, - {"latitude": 1.0, "longitude": "1.0"}, ), ), ), -- GitLab