Add missing attribution (#22964)

This commit is contained in:
Fabian Affolter
2019-04-10 14:51:42 +02:00
committed by Sebastian Muszynski
parent 691271147e
commit f4309dfcc6

View File

@@ -1,11 +1,12 @@
"""Sensor for checking the status of London Underground tube lines.""" """Sensor for checking the status of London Underground tube lines."""
import logging
from datetime import timedelta from datetime import timedelta
import logging
import voluptuous as vol import voluptuous as vol
import homeassistant.helpers.config_validation as cv
from homeassistant.components.sensor import PLATFORM_SCHEMA from homeassistant.components.sensor import PLATFORM_SCHEMA
from homeassistant.const import ATTR_ATTRIBUTION
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entity import Entity from homeassistant.helpers.entity import Entity
REQUIREMENTS = ['london-tube-status==0.2'] REQUIREMENTS = ['london-tube-status==0.2']
@@ -16,6 +17,8 @@ ATTRIBUTION = "Powered by TfL Open Data"
CONF_LINE = 'line' CONF_LINE = 'line'
ICON = 'mdi:subway'
SCAN_INTERVAL = timedelta(seconds=30) SCAN_INTERVAL = timedelta(seconds=30)
TUBE_LINES = [ TUBE_LINES = [
@@ -54,16 +57,15 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
class LondonTubeSensor(Entity): class LondonTubeSensor(Entity):
"""Sensor that reads the status of a line from TubeData.""" """Sensor that reads the status of a line from Tube Data."""
ICON = 'mdi:subway'
def __init__(self, name, data): def __init__(self, name, data):
"""Initialize the sensor.""" """Initialize the London Underground sensor."""
self._name = name
self._data = data self._data = data
self._state = None
self._description = None self._description = None
self._name = name
self._state = None
self.attrs = {ATTR_ATTRIBUTION: ATTRIBUTION}
@property @property
def name(self): def name(self):
@@ -78,14 +80,13 @@ class LondonTubeSensor(Entity):
@property @property
def icon(self): def icon(self):
"""Icon to use in the frontend, if any.""" """Icon to use in the frontend, if any."""
return self.ICON return ICON
@property @property
def device_state_attributes(self): def device_state_attributes(self):
"""Return other details about the sensor state.""" """Return other details about the sensor state."""
attrs = {} self.attrs['Description'] = self._description
attrs['Description'] = self._description return self.attrs
return attrs
def update(self): def update(self):
"""Update the sensor.""" """Update the sensor."""