Upgrade coinbase to 2.0.7 (#11992)
This commit is contained in:
parent
336bdb1889
commit
96f9a12541
3 changed files with 26 additions and 25 deletions
|
@ -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)
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue