diff --git a/homeassistant/components/coinbase.py b/homeassistant/components/coinbase.py index bdb091325cf..10123752c99 100644 --- a/homeassistant/components/coinbase.py +++ b/homeassistant/components/coinbase.py @@ -5,16 +5,17 @@ For more details about this component, please refer to the documentation at https://home-assistant.io/components/coinbase/ """ from datetime import timedelta - import logging + import voluptuous as vol -import homeassistant.helpers.config_validation as cv from homeassistant.const import CONF_API_KEY -from homeassistant.util import Throttle +import homeassistant.helpers.config_validation as cv from homeassistant.helpers.discovery import load_platform +from homeassistant.util import Throttle + +REQUIREMENTS = ['coinbase==2.0.7'] -REQUIREMENTS = ['coinbase==2.0.6'] _LOGGER = logging.getLogger(__name__) DOMAIN = 'coinbase' @@ -46,14 +47,13 @@ def setup(hass, config): api_secret = config[DOMAIN].get(CONF_API_SECRET) exchange_currencies = config[DOMAIN].get(CONF_EXCHANGE_CURRENCIES) - hass.data[DATA_COINBASE] = coinbase_data = CoinbaseData(api_key, - api_secret) + hass.data[DATA_COINBASE] = coinbase_data = CoinbaseData( + api_key, api_secret) if not hasattr(coinbase_data, 'accounts'): return False for account in coinbase_data.accounts.data: - load_platform(hass, 'sensor', DOMAIN, - {'account': account}, config) + load_platform(hass, 'sensor', DOMAIN, {'account': account}, config) for currency in exchange_currencies: if currency not in coinbase_data.exchange_rates.rates: _LOGGER.warning("Currency %s not found", currency) diff --git a/homeassistant/components/sensor/coinbase.py b/homeassistant/components/sensor/coinbase.py index d66c7d4e4b6..32e1d8f211a 100644 --- a/homeassistant/components/sensor/coinbase.py +++ b/homeassistant/components/sensor/coinbase.py @@ -4,21 +4,22 @@ Support for Coinbase sensors. For more details about this platform, please refer to the documentation at https://home-assistant.io/components/sensor.coinbase/ """ -from homeassistant.helpers.entity import Entity from homeassistant.const import ATTR_ATTRIBUTION +from homeassistant.helpers.entity import Entity - -DEPENDENCIES = ['coinbase'] - -DATA_COINBASE = 'coinbase_cache' - -CONF_ATTRIBUTION = "Data provided by coinbase.com" ATTR_NATIVE_BALANCE = "Balance in native currency" BTC_ICON = 'mdi:currency-btc' -ETH_ICON = 'mdi:currency-eth' + 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_devices, discovery_info=None): """Set up the Coinbase sensors.""" @@ -26,13 +27,13 @@ def setup_platform(hass, config, add_devices, discovery_info=None): return if 'account' in discovery_info: account = discovery_info['account'] - sensor = AccountSensor(hass.data[DATA_COINBASE], - account['name'], - account['balance']['currency']) + sensor = AccountSensor( + hass.data[DATA_COINBASE], account['name'], + account['balance']['currency']) if 'exchange_currency' in discovery_info: - sensor = ExchangeRateSensor(hass.data[DATA_COINBASE], - discovery_info['exchange_currency'], - discovery_info['native_currency']) + sensor = ExchangeRateSensor( + hass.data[DATA_COINBASE], discovery_info['exchange_currency'], + discovery_info['native_currency']) add_devices([sensor], True) @@ -78,8 +79,8 @@ class AccountSensor(Entity): """Return the state attributes of the sensor.""" return { ATTR_ATTRIBUTION: CONF_ATTRIBUTION, - ATTR_NATIVE_BALANCE: "{} {}".format(self._native_balance, - self._native_currency) + ATTR_NATIVE_BALANCE: "{} {}".format( + self._native_balance, self._native_currency), } def update(self): diff --git a/requirements_all.txt b/requirements_all.txt index 0528871c05b..ce83183a89a 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -170,7 +170,7 @@ caldav==0.5.0 ciscosparkapi==0.4.2 # homeassistant.components.coinbase -coinbase==2.0.6 +coinbase==2.0.7 # homeassistant.components.sensor.coinmarketcap coinmarketcap==4.2.1