Skip to content

Commit

Permalink
"distance" => "home_distance"
Browse files Browse the repository at this point in the history
  • Loading branch information
amitfin committed Oct 17, 2024
1 parent 19f639a commit c13c8f0
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion custom_components/oref_alert/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
ATTR_AREA: Final = "area"
ATTR_COUNTRY_ALERTS: Final = "country_alerts"
ATTR_COUNTRY_ACTIVE_ALERTS: Final = "country_active_alerts"
ATTR_DISTANCE: Final = "distance"
ATTR_HOME_DISTANCE: Final = "home_distance"
ATTR_SELECTED_AREAS_ALERTS: Final = "selected_areas_alerts"
ATTR_SELECTED_AREAS_ACTIVE_ALERTS: Final = "selected_areas_active_alerts"
ATTR_TIME_TO_SHELTER: Final = "time_to_shelter"
Expand Down
6 changes: 3 additions & 3 deletions custom_components/oref_alert/geo_location.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from homeassistant.util.location import vincenty

from .const import (
ATTR_DISTANCE,
ATTR_HOME_DISTANCE,
DATA_COORDINATOR,
DOMAIN,
IST,
Expand Down Expand Up @@ -56,7 +56,7 @@ class OrefAlertLocationEvent(GeolocationEvent):
ATTR_LATITUDE,
ATTR_LONGITUDE,
ATTR_DATE,
ATTR_DISTANCE,
ATTR_HOME_DISTANCE,
CONF_FRIENDLY_NAME,
CONF_UNIT_OF_MEASUREMENT,
"category",
Expand Down Expand Up @@ -84,7 +84,7 @@ def __init__(
or 0,
1,
)
self._alert_attributes = {**attributes, ATTR_DISTANCE: self._attr_distance}
self._alert_attributes = {**attributes, ATTR_HOME_DISTANCE: self._attr_distance}

@property
def suggested_object_id(self) -> str | None:
Expand Down
7 changes: 4 additions & 3 deletions tests/test_geo_location.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
)

from custom_components.oref_alert.const import (
ATTR_DISTANCE,
ATTR_HOME_DISTANCE,
CONF_ALERT_ACTIVE_DURATION,
CONF_AREAS,
CONF_POLL_INTERVAL,
Expand Down Expand Up @@ -90,7 +90,7 @@ async def test_entity(
assert state.attributes[ATTR_LONGITUDE] == 34.4926
assert state.attributes[CONF_UNIT_OF_MEASUREMENT] == UnitOfLength.KILOMETERS
assert state.attributes[CONF_FRIENDLY_NAME] == "בארי"
assert state.attributes[ATTR_DISTANCE] == 80.6
assert state.attributes[ATTR_HOME_DISTANCE] == 80.6
assert state.attributes[ATTR_DATE] == dt_util.parse_datetime(
"2023-10-07 06:30:00+03:00"
)
Expand Down Expand Up @@ -194,7 +194,8 @@ async def test_distance_types(
)
assert result_as_boolean(
Template(
f"{{{{ states.{ENTITY_ID}.attributes.{ATTR_DISTANCE} is float }}}}", hass
f"{{{{ states.{ENTITY_ID}.attributes.{ATTR_HOME_DISTANCE} is float }}}}",
hass,
).async_render(parse_result=False)
)
await async_shutdown(hass, config_id)

0 comments on commit c13c8f0

Please sign in to comment.