Accept integer coordinates in has_location helper (#159835)

Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
Co-authored-by: Artur Pragacz <49985303+arturpragacz@users.noreply.github.com>
This commit is contained in:
doomsniper09
2025-12-30 13:06:23 +02:00
committed by GitHub
parent 2d1a672de5
commit 8370c6abfb
2 changed files with 8 additions and 2 deletions

View File

@@ -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))
)

View File

@@ -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")