Add/adjust attribution of sensor platform (#3719)

* Add/adjust attribution

* Fix typo
This commit is contained in:
Fabian Affolter authored and Paulus Schoutsen committed 2016-10-11 00:28:19 -07:00
1 parent 7cf2c48175
commit 8ded8f572a
12 files changed
+101 -57

No files matched your search

+10 -8
View File
@@ -10,7 +10,7 @@ from datetime import timedelta
import voluptuous as vol
from homeassistant.components.sensor import PLATFORM_SCHEMA
from homeassistant.const import CONF_NAME
from homeassistant.const import CONF_NAME, ATTR_ATTRIBUTION
from homeassistant.helpers.entity import Entity
from homeassistant.util import Throttle
import homeassistant.helpers.config_validation as cv
@@ -19,6 +19,11 @@ REQUIREMENTS = ['fixerio==0.1.1']
_LOGGER = logging.getLogger(__name__)
ATTR_BASE = 'Base currency'
ATTR_EXCHANGE_RATE = 'Exchange rate'
ATTR_TARGET = 'Target currency'
CONF_ATTRIBUTION = "Data provided by the European Central Bank (ECB)"
CONF_BASE = 'base'
CONF_TARGET = 'target'
@@ -29,10 +34,6 @@ ICON = 'mdi:currency'
MIN_TIME_BETWEEN_UPDATES = timedelta(days=1)
STATE_ATTR_BASE = 'Base currency'
STATE_ATTR_EXCHANGE_RATE = 'Exchange rate'
STATE_ATTR_TARGET = 'Target currency'
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
vol.Required(CONF_TARGET): cv.string,
vol.Optional(CONF_BASE, default=DEFAULT_BASE): cv.string,
@@ -90,9 +91,10 @@ class ExchangeRateSensor(Entity):
"""Return the state attributes."""
if self.data.rate is not None:
return {
STATE_ATTR_BASE: self.data.rate['base'],
STATE_ATTR_TARGET: self._target,
STATE_ATTR_EXCHANGE_RATE: self.data.rate['rates'][self._target]
ATTR_BASE: self.data.rate['base'],
ATTR_TARGET: self._target,
ATTR_EXCHANGE_RATE: self.data.rate['rates'][self._target],
ATTR_ATTRIBUTION: CONF_ATTRIBUTION,
}
@property