added more debug logging for sensor.alpha_vantage (#12249)

* added more debug logging for sensor.alpha_vantage

* fixed typo in log statement, more fine grained logging

* Capitalized first character in log statement

* replaced quotes as proposed by @OttoWinter
pull/12254/merge
ChristianKuehnel 2018-02-09 00:14:49 +01:00 committed by Fabian Affolter
parent acb521330c
commit b08294386b
1 changed files with 13 additions and 0 deletions

View File

@ -89,6 +89,8 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
dev = []
for symbol in symbols:
try:
_LOGGER.debug("Configuring timeseries for symbols: %s",
symbol[CONF_SYMBOL])
timeseries.get_intraday(symbol[CONF_SYMBOL])
except ValueError:
_LOGGER.error(
@ -100,6 +102,8 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
from_cur = conversion.get(CONF_FROM)
to_cur = conversion.get(CONF_TO)
try:
_LOGGER.debug("Configuring forex %s - %s",
from_cur, to_cur)
forex.get_currency_exchange_rate(
from_currency=from_cur, to_currency=to_cur)
except ValueError as error:
@ -110,6 +114,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
dev.append(AlphaVantageForeignExchange(forex, conversion))
add_devices(dev, True)
_LOGGER.debug("Setup completed")
class AlphaVantageSensor(Entity):
@ -158,8 +163,10 @@ class AlphaVantageSensor(Entity):
def update(self):
"""Get the latest data and updates the states."""
_LOGGER.debug("Requesting new data for symbol %s", self._symbol)
all_values, _ = self._timeseries.get_intraday(self._symbol)
self.values = next(iter(all_values.values()))
_LOGGER.debug("Received new values for symbol %s", self._symbol)
class AlphaVantageForeignExchange(Entity):
@ -210,5 +217,11 @@ class AlphaVantageForeignExchange(Entity):
def update(self):
"""Get the latest data and updates the states."""
_LOGGER.debug("Requesting new data for forex %s - %s",
self._from_currency,
self._to_currency)
self.values, _ = self._foreign_exchange.get_currency_exchange_rate(
from_currency=self._from_currency, to_currency=self._to_currency)
_LOGGER.debug("Received new data for forex %s - %s",
self._from_currency,
self._to_currency)