Bitcoin sensor use warning instead of error (#3103)
parent
1094de7ad9
commit
748d7f4ecb
|
@ -17,6 +17,16 @@ from homeassistant.util import Throttle
|
|||
|
||||
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 = {
|
||||
'exchangerate': ['Exchange rate (1 BTC)', None],
|
||||
'trade_volume_btc': ['Trade volume', 'BTC'],
|
||||
|
@ -41,20 +51,12 @@ OPTION_TYPES = {
|
|||
'market_price_usd': ['Market price', 'USD']
|
||||
}
|
||||
|
||||
ICON = 'mdi:currency-btc'
|
||||
CONF_CURRENCY = 'currency'
|
||||
|
||||
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
||||
vol.Required(CONF_DISPLAY_OPTIONS, default=[]):
|
||||
[vol.In(OPTION_TYPES)],
|
||||
vol.Optional(CONF_CURRENCY, default='USD'): cv.string,
|
||||
vol.All(cv.ensure_list, [vol.In(OPTION_TYPES)]),
|
||||
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):
|
||||
"""Setup the Bitcoin sensors."""
|
||||
|
@ -63,8 +65,9 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
|||
currency = config.get(CONF_CURRENCY)
|
||||
|
||||
if currency not in exchangerates.get_ticker():
|
||||
_LOGGER.error('Currency "%s" is not available. Using "USD"', currency)
|
||||
currency = 'USD'
|
||||
_LOGGER.warning('Currency "%s" is not available. Using "USD"',
|
||||
currency)
|
||||
currency = DEFAULT_CURRENCY
|
||||
|
||||
data = BitcoinData()
|
||||
dev = []
|
||||
|
|
Loading…
Reference in New Issue