Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 10 additions & 15 deletions homeassistant/components/sensor/coinbase.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,20 @@

ATTR_NATIVE_BALANCE = "Balance in native currency"

BTC_ICON = 'mdi:currency-btc'

COIN_ICON = 'mdi:coin'
CURRENCY_ICONS = {
'BTC': 'mdi:currency-btc',
'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"

DATA_COINBASE = 'coinbase_cache'
DEPENDENCIES = ['coinbase']

ETH_ICON = 'mdi:currency-eth'


def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the Coinbase sensors."""
Expand Down Expand Up @@ -68,11 +71,7 @@ def unit_of_measurement(self):
@property
def icon(self):
"""Return the icon to use in the frontend, if any."""
if self._name == "Coinbase BTC Wallet":
return BTC_ICON
if self._name == "Coinbase ETH Wallet":
return ETH_ICON
return COIN_ICON
return CURRENCY_ICONS.get(self._unit_of_measurement, DEFAULT_COIN_ICON)

@property
def device_state_attributes(self):
Expand Down Expand Up @@ -122,11 +121,7 @@ def unit_of_measurement(self):
@property
def icon(self):
"""Return the icon to use in the frontend, if any."""
if self._name == "BTC Exchange Rate":
return BTC_ICON
if self._name == "ETH Exchange Rate":
return ETH_ICON
return COIN_ICON
return CURRENCY_ICONS.get(self.currency, DEFAULT_COIN_ICON)

@property
def device_state_attributes(self):
Expand Down