mirror of
https://github.com/Electric-Special/ha-core.git
synced 2026-03-21 02:03:27 +01:00
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:
@@ -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))
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user