Move icon constants to entity attributes (#90518)

* Move icon constants to attribute

* Adjust test
This commit is contained in:
epenet 2023-03-31 09:34:17 +02:00 committed by GitHub
parent 2e0ecf9bd9
commit d0c38c1e12
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
29 changed files with 46 additions and 177 deletions

View file

@ -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()