From 8370c6abfbebf74a770ad512dbcc090acda4ef25 Mon Sep 17 00:00:00 2001 From: doomsniper09 <79980810+doomsniper09@users.noreply.github.com> Date: Tue, 30 Dec 2025 13:06:23 +0200 Subject: [PATCH] Accept integer coordinates in has_location helper (#159835) Co-authored-by: Paulus Schoutsen Co-authored-by: Artur Pragacz <49985303+arturpragacz@users.noreply.github.com> --- homeassistant/helpers/location.py | 4 ++-- tests/helpers/test_location.py | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/homeassistant/helpers/location.py b/homeassistant/helpers/location.py index 5264869d037..10923b0693c 100644 --- a/homeassistant/helpers/location.py +++ b/homeassistant/helpers/location.py @@ -19,8 +19,8 @@ def has_location(state: State) -> bool: """ return ( isinstance(state, State) - and isinstance(state.attributes.get(ATTR_LATITUDE), float) - and isinstance(state.attributes.get(ATTR_LONGITUDE), float) + and isinstance(state.attributes.get(ATTR_LATITUDE), (float, int)) + and isinstance(state.attributes.get(ATTR_LONGITUDE), (float, int)) ) diff --git a/tests/helpers/test_location.py b/tests/helpers/test_location.py index 4c14433188c..11c235e611b 100644 --- a/tests/helpers/test_location.py +++ b/tests/helpers/test_location.py @@ -27,6 +27,12 @@ def test_has_location_with_states_with_valid_location() -> None: assert location.has_location(state) +def test_has_location_with_states_with_int_location() -> None: + """Test that integer coordinates are valid.""" + state = State("hello.world", "valid", {ATTR_LATITUDE: 123, ATTR_LONGITUDE: 45}) + assert location.has_location(state) + + def test_closest_with_no_states_with_location() -> None: """Set up the tests.""" state = State("light.test", "on")