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