Skip to content

Commit

Permalink
Add vehicle_id and monitored flag to data for each departure.
Browse files Browse the repository at this point in the history
This adds two more attributes for each departure, to allow extraction by anyone
interested in monitoring these.

Issue #8
  • Loading branch information
make-all committed Jul 3, 2023
1 parent b42763e commit 18ff4a0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ If your stop is busy with multiple routes, you can filter by route and/or destin
Each stop will create a sensor in Home Assistant, which will return the next departure time as its status.

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

Expand Down
5 changes: 5 additions & 0 deletions custom_components/metlink/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,14 @@
ATTR_DESTINATION,
ATTR_DESTINATION_ID,
ATTR_EXPECTED,
ATTR_MONITORED,
ATTR_NAME,
ATTR_OPERATOR,
ATTR_SERVICE,
ATTR_STATUS,
ATTR_STOP,
ATTR_STOP_NAME,
ATTR_VEHICLE,
ATTRIBUTION,
CONF_DEST,
CONF_NUM_DEPARTURES,
Expand Down Expand Up @@ -269,6 +271,9 @@ async def async_update(self):
self.attrs[ATTR_DELAY + suffix] = int(
parse_duration(departure[ATTR_DELAY]) / timedelta(minutes=1)
)
self.attrs[ATTR_MONITORED + suffix] = departure[ATTR_MONITORED]
self.attrs[ATTR_VEHICLE + suffix] = departure[ATTR_VEHICLE]

self._available = True
# Clear out the unused slots
for i in range(num, self.num_departures):
Expand Down

0 comments on commit 18ff4a0

Please sign in to comment.