mirror of
https://github.com/home-assistant/core.git
synced 2025-07-24 21:57:51 +00:00
Update Coinbase icons (#18172)
* Add extra icons and don't rely on the name * Use dictionary for icons use safe get() with default value * Use better vars
This commit is contained in:
parent
5418e0510d
commit
42cb23f768
@ -9,17 +9,20 @@ from homeassistant.helpers.entity import Entity
|
|||||||
|
|
||||||
ATTR_NATIVE_BALANCE = "Balance in native currency"
|
ATTR_NATIVE_BALANCE = "Balance in native currency"
|
||||||
|
|
||||||
BTC_ICON = 'mdi:currency-btc'
|
CURRENCY_ICONS = {
|
||||||
|
'BTC': 'mdi:currency-btc',
|
||||||
COIN_ICON = 'mdi:coin'
|
'ETH': 'mdi:currency-eth',
|
||||||
|
'EUR': 'mdi:currency-eur',
|
||||||
|
'LTC': 'mdi:litecoin',
|
||||||
|
'USD': 'mdi:currency-usd'
|
||||||
|
}
|
||||||
|
DEFAULT_COIN_ICON = 'mdi:coin'
|
||||||
|
|
||||||
CONF_ATTRIBUTION = "Data provided by coinbase.com"
|
CONF_ATTRIBUTION = "Data provided by coinbase.com"
|
||||||
|
|
||||||
DATA_COINBASE = 'coinbase_cache'
|
DATA_COINBASE = 'coinbase_cache'
|
||||||
DEPENDENCIES = ['coinbase']
|
DEPENDENCIES = ['coinbase']
|
||||||
|
|
||||||
ETH_ICON = 'mdi:currency-eth'
|
|
||||||
|
|
||||||
|
|
||||||
def setup_platform(hass, config, add_entities, discovery_info=None):
|
def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||||
"""Set up the Coinbase sensors."""
|
"""Set up the Coinbase sensors."""
|
||||||
@ -68,11 +71,7 @@ class AccountSensor(Entity):
|
|||||||
@property
|
@property
|
||||||
def icon(self):
|
def icon(self):
|
||||||
"""Return the icon to use in the frontend, if any."""
|
"""Return the icon to use in the frontend, if any."""
|
||||||
if self._name == "Coinbase BTC Wallet":
|
return CURRENCY_ICONS.get(self._unit_of_measurement, DEFAULT_COIN_ICON)
|
||||||
return BTC_ICON
|
|
||||||
if self._name == "Coinbase ETH Wallet":
|
|
||||||
return ETH_ICON
|
|
||||||
return COIN_ICON
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def device_state_attributes(self):
|
def device_state_attributes(self):
|
||||||
@ -122,11 +121,7 @@ class ExchangeRateSensor(Entity):
|
|||||||
@property
|
@property
|
||||||
def icon(self):
|
def icon(self):
|
||||||
"""Return the icon to use in the frontend, if any."""
|
"""Return the icon to use in the frontend, if any."""
|
||||||
if self._name == "BTC Exchange Rate":
|
return CURRENCY_ICONS.get(self.currency, DEFAULT_COIN_ICON)
|
||||||
return BTC_ICON
|
|
||||||
if self._name == "ETH Exchange Rate":
|
|
||||||
return ETH_ICON
|
|
||||||
return COIN_ICON
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def device_state_attributes(self):
|
def device_state_attributes(self):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user