Bitcoin sensor use warning instead of error (#3103)
This commit is contained in:
parent
1094de7ad9
commit
748d7f4ecb
1 changed files with 15 additions and 12 deletions
|
@ -17,6 +17,16 @@ from homeassistant.util import Throttle
|
||||||
|
|
||||||
REQUIREMENTS = ['blockchain==1.3.3']
|
REQUIREMENTS = ['blockchain==1.3.3']
|
||||||
|
|
||||||
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
CONF_CURRENCY = 'currency'
|
||||||
|
|
||||||
|
DEFAULT_CURRENCY = 'USD'
|
||||||
|
|
||||||
|
ICON = 'mdi:currency-btc'
|
||||||
|
|
||||||
|
MIN_TIME_BETWEEN_UPDATES = timedelta(minutes=5)
|
||||||
|
|
||||||
OPTION_TYPES = {
|
OPTION_TYPES = {
|
||||||
'exchangerate': ['Exchange rate (1 BTC)', None],
|
'exchangerate': ['Exchange rate (1 BTC)', None],
|
||||||
'trade_volume_btc': ['Trade volume', 'BTC'],
|
'trade_volume_btc': ['Trade volume', 'BTC'],
|
||||||
|
@ -41,20 +51,12 @@ OPTION_TYPES = {
|
||||||
'market_price_usd': ['Market price', 'USD']
|
'market_price_usd': ['Market price', 'USD']
|
||||||
}
|
}
|
||||||
|
|
||||||
ICON = 'mdi:currency-btc'
|
|
||||||
CONF_CURRENCY = 'currency'
|
|
||||||
|
|
||||||
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
||||||
vol.Required(CONF_DISPLAY_OPTIONS, default=[]):
|
vol.Required(CONF_DISPLAY_OPTIONS, default=[]):
|
||||||
[vol.In(OPTION_TYPES)],
|
vol.All(cv.ensure_list, [vol.In(OPTION_TYPES)]),
|
||||||
vol.Optional(CONF_CURRENCY, default='USD'): cv.string,
|
vol.Optional(CONF_CURRENCY, default=DEFAULT_CURRENCY): cv.string,
|
||||||
})
|
})
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
|
||||||
|
|
||||||
# Return cached results if last scan was less then this time ago.
|
|
||||||
MIN_TIME_BETWEEN_UPDATES = timedelta(minutes=5)
|
|
||||||
|
|
||||||
|
|
||||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||||
"""Setup the Bitcoin sensors."""
|
"""Setup the Bitcoin sensors."""
|
||||||
|
@ -63,8 +65,9 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||||
currency = config.get(CONF_CURRENCY)
|
currency = config.get(CONF_CURRENCY)
|
||||||
|
|
||||||
if currency not in exchangerates.get_ticker():
|
if currency not in exchangerates.get_ticker():
|
||||||
_LOGGER.error('Currency "%s" is not available. Using "USD"', currency)
|
_LOGGER.warning('Currency "%s" is not available. Using "USD"',
|
||||||
currency = 'USD'
|
currency)
|
||||||
|
currency = DEFAULT_CURRENCY
|
||||||
|
|
||||||
data = BitcoinData()
|
data = BitcoinData()
|
||||||
dev = []
|
dev = []
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue