Move icon constants to entity attributes (#90518)
* Move icon constants to attribute * Adjust test
This commit is contained in:
parent
2e0ecf9bd9
commit
d0c38c1e12
29 changed files with 46 additions and 177 deletions
|
@ -19,12 +19,10 @@ _LOGGER = logging.getLogger(__name__)
|
|||
|
||||
ATTR_EXCHANGE_RATE = "Exchange rate"
|
||||
ATTR_TARGET = "Target currency"
|
||||
ATTRIBUTION = "Data provided by the European Central Bank (ECB)"
|
||||
|
||||
DEFAULT_BASE = "USD"
|
||||
DEFAULT_NAME = "Exchange rate"
|
||||
|
||||
ICON = "mdi:currency-usd"
|
||||
|
||||
SCAN_INTERVAL = timedelta(days=1)
|
||||
|
||||
|
@ -61,7 +59,8 @@ def setup_platform(
|
|||
class ExchangeRateSensor(SensorEntity):
|
||||
"""Representation of a Exchange sensor."""
|
||||
|
||||
_attr_attribution = ATTRIBUTION
|
||||
_attr_attribution = "Data provided by the European Central Bank (ECB)"
|
||||
_attr_icon = "mdi:currency-usd"
|
||||
|
||||
def __init__(self, data, name, target):
|
||||
"""Initialize the sensor."""
|
||||
|
@ -94,11 +93,6 @@ class ExchangeRateSensor(SensorEntity):
|
|||
ATTR_TARGET: self._target,
|
||||
}
|
||||
|
||||
@property
|
||||
def icon(self):
|
||||
"""Return the icon to use in the frontend, if any."""
|
||||
return ICON
|
||||
|
||||
def update(self) -> None:
|
||||
"""Get the latest data and updates the states."""
|
||||
self.data.update()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue