Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion homeassistant/components/sensor/gtfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,16 @@
DEFAULT_PATH = 'gtfs'

ICON = 'mdi:train'
ICONS = {
0: 'mdi:tram',
1: 'mdi:subway',
2: 'mdi:train',
3: 'mdi:bus',
4: 'mdi:ferry',
5: 'mdi:train-variant',
6: 'mdi:gondola',
7: 'mdi:stairs',
}

TIME_FORMAT = '%Y-%m-%d %H:%M:%S'

Expand Down Expand Up @@ -193,6 +203,7 @@ def __init__(self, pygtfs, name, origin, destination, offset):
self.destination = destination
self._offset = offset
self._custom_name = name
self._icon = ICON
self._name = ''
self._unit_of_measurement = 'min'
self._state = 0
Expand Down Expand Up @@ -223,7 +234,7 @@ def device_state_attributes(self):
@property
def icon(self):
"""Icon to use in the frontend, if any."""
return ICON
return self._icon

def update(self):
"""Get the latest data from GTFS and update the states."""
Expand Down Expand Up @@ -257,6 +268,8 @@ def update(self):
self._attributes = {}
self._attributes['offset'] = self._offset.seconds / 60

self._icon = ICONS.get(route.route_type, ICON)

def dict_for_table(resource):
"""Return a dict for the SQLAlchemy resource given."""
return dict((col, getattr(resource, col))
Expand Down