NSW Rural Fire Service icon for geolocation entities (#26416)

* define icon

* add myself as codeowner
This commit is contained in:
Malte Franken 2019-09-04 19:33:29 +10:00 committed by Martin Hjelmare
parent c191551091
commit d1bc0c1dd9
4 changed files with 15 additions and 1 deletions

View File

@ -191,6 +191,7 @@ homeassistant/components/no_ip/* @fabaff
homeassistant/components/notify/* @home-assistant/core
homeassistant/components/notion/* @bachya
homeassistant/components/nsw_fuel_station/* @nickw444
homeassistant/components/nsw_rural_fire_service_feed/* @exxamalte
homeassistant/components/nuki/* @pschmitt
homeassistant/components/nws/* @MatthewFlamm
homeassistant/components/ohmconnect/* @robbiet480

View File

@ -210,6 +210,13 @@ class NswRuralFireServiceLocationEvent(GeolocationEvent):
self._size = feed_entry.size
self._responsible_agency = feed_entry.responsible_agency
@property
def icon(self):
"""Return the icon to use in the frontend."""
if self._fire:
return "mdi:fire"
return "mdi:alarm-light"
@property
def source(self) -> str:
"""Return source value of this external event."""

View File

@ -6,5 +6,7 @@
"geojson_client==0.4"
],
"dependencies": [],
"codeowners": []
"codeowners": [
"@exxamalte"
]
}

View File

@ -27,6 +27,7 @@ from homeassistant.const import (
CONF_LONGITUDE,
CONF_RADIUS,
EVENT_HOMEASSISTANT_START,
ATTR_ICON,
)
from homeassistant.setup import async_setup_component
from tests.common import assert_setup_component, async_fire_time_changed
@ -150,6 +151,7 @@ async def test_setup(hass):
ATTR_RESPONSIBLE_AGENCY: "Agency 1",
ATTR_UNIT_OF_MEASUREMENT: "km",
ATTR_SOURCE: "nsw_rural_fire_service_feed",
ATTR_ICON: "mdi:fire",
}
assert round(abs(float(state.state) - 15.5), 7) == 0
@ -164,6 +166,7 @@ async def test_setup(hass):
ATTR_FIRE: False,
ATTR_UNIT_OF_MEASUREMENT: "km",
ATTR_SOURCE: "nsw_rural_fire_service_feed",
ATTR_ICON: "mdi:alarm-light",
}
assert round(abs(float(state.state) - 20.5), 7) == 0
@ -178,6 +181,7 @@ async def test_setup(hass):
ATTR_FIRE: True,
ATTR_UNIT_OF_MEASUREMENT: "km",
ATTR_SOURCE: "nsw_rural_fire_service_feed",
ATTR_ICON: "mdi:fire",
}
assert round(abs(float(state.state) - 25.5), 7) == 0