Skip to content

Commit 18ff4a0

Browse files
committed
Add vehicle_id and monitored flag to data for each departure.
This adds two more attributes for each departure, to allow extraction by anyone interested in monitoring these. Issue #8
1 parent b42763e commit 18ff4a0

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ If your stop is busy with multiple routes, you can filter by route and/or destin
3838
Each stop will create a sensor in Home Assistant, which will return the next departure time as its status.
3939

4040
It will also return attributes for departure time, service, service
41-
name, destination name, stop id for the destination, and status. The
41+
name, destination name, stop id for the destination, status and more. The
4242
duplication of departure time in the attributes makes more sense when
4343
there is more than one result being returned.
4444

custom_components/metlink/sensor.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,14 @@
4040
ATTR_DESTINATION,
4141
ATTR_DESTINATION_ID,
4242
ATTR_EXPECTED,
43+
ATTR_MONITORED,
4344
ATTR_NAME,
4445
ATTR_OPERATOR,
4546
ATTR_SERVICE,
4647
ATTR_STATUS,
4748
ATTR_STOP,
4849
ATTR_STOP_NAME,
50+
ATTR_VEHICLE,
4951
ATTRIBUTION,
5052
CONF_DEST,
5153
CONF_NUM_DEPARTURES,
@@ -269,6 +271,9 @@ async def async_update(self):
269271
self.attrs[ATTR_DELAY + suffix] = int(
270272
parse_duration(departure[ATTR_DELAY]) / timedelta(minutes=1)
271273
)
274+
self.attrs[ATTR_MONITORED + suffix] = departure[ATTR_MONITORED]
275+
self.attrs[ATTR_VEHICLE + suffix] = departure[ATTR_VEHICLE]
276+
272277
self._available = True
273278
# Clear out the unused slots
274279
for i in range(num, self.num_departures):

0 commit comments

Comments
 (0)