Skip to content

Commit

Permalink
Merge branch 'dev' of https://github.com/vingerha/gtfs2 into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
vingerha committed Nov 18, 2023
2 parents 0215fd7 + 377af8c commit 219d558
Show file tree
Hide file tree
Showing 2 changed files with 102 additions and 92 deletions.
39 changes: 26 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,21 @@ Core GTFS uses start + stop, it then determines every option between them and pr
***Solution/workaround in GTFS2***: attribute added: next_departure_line shows all next departues with their line/means-of-transport. So even if you select a route first and then two stops, the attibutes will still show alternatives between those 2 stops, if applicable.

## Updates
- 20231104: initial version

## ToDo's
202311DD
- realtime vehile tracking with geojson output
- workflow tweaks
- extend update service call
20231110: adding features:
- new attribute: next_departure_headsigns
- adding route shortname in selection/list to overcome data discrepancies been short name and long name
- for new datasource, allow to use a self-placed zip file in the gtfs2 folder. This for zip that are not available via URL or zip with data that may need modification to comply with extraction conditions by pygtfs
- timezone for next_departure is now used in order: agency (delivering data), if not > HA system, if not > UTC. This to resolve TZ issues for datasets without agency (timezone)

20231104: initial version

## ToDo's / In Development
- Issue when updating the source db, it throws a db locked error. This when an existing entity for the same db starts polling it at the same time
- Icon for the integration (brands)
- (DONE) Icon for the integration (brands)
- bypass setup control for routes that have no trips 'today'. The configuration does a spot-check if start/end actually return data with the idea to validate the setup. However, this only checks for 'today' so if your route actually has no transport running at the day of setup (say Sunday or Holiday) then it will reject it.

## Installation via HACS :
Expand All @@ -39,28 +49,31 @@ Use the workflow

Example: https://github.com/vingerha/gtfs2/blob/main/example.md

**IMPORTANT**
## Real Time vehicle tracking

As per v1.6, the vehicle tracking output coordinates to geojson file in your www folder, which in turn can then be consumed by the geosjon integration and map card https://www.home-assistant.io/integrations/geo_json_events/
![image](https://github.com/vingerha/gtfs2/assets/44190435/a3cbea60-46f1-40e9-88c5-4b9a0519c782)


## **IMPORTANT**
- sources need to adhere to GTFS standards both for static data (zip/sqlite) as well as for real-time data (binary).
- certain providers publish large zip-files which in turn will result in much larger db files. Unpacking may take a long time (depending HA server perf.). Example for a 117Mb zip: ~2hrs to unpack to a 7Gb sqlite
- for these large db, performance may be slow too, there is a PR to improve this by adding indexes to the stop_times table
- the integration uses folder /config/gtfs2 to store the datafiles (zip and sqlite)
- the integration uses folder /config/www for geojson files, only available when using verhical tracking sources

## Data add / update
Data can be updated at your own discretion by a service, e.g. you can have a weekly automation to run the service
**Note:** for "update" to work, the name should be the ***same*** as the existing source. It will first remove the existing one and reload the one as per your URL

![image](https://github.com/vingerha/gtfs2/assets/44190435/2defc23d-a1a0-40be-b610-6c5360fbd464)

or via yaml
![image](https://github.com/vingerha/gtfs2/assets/44190435/2d639afa-376b-4956-8223-2c982dc537cb)

![image](https://github.com/vingerha/gtfs2/assets/44190435/2fea7926-a64d-43b6-a653-c95f1f01c66d)

or via yaml

![image](https://github.com/vingerha/gtfs2/assets/44190435/0d50bb87-c081-4cd6-8dc5-9603a44c21a4)


## Thank you
- @joostlek ... massive thanks to help me through many (!) tech aspects and getting this to the inital version
- @mxbssn for initiating, bringing ideas, helping with testing



- @mark1foley for his gtfs real time integration which was enhanced with its integration in GTFS2
155 changes: 76 additions & 79 deletions example.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,116 +39,113 @@ You can add a optional area

![image](https://github.com/vingerha/gtfs2/assets/44190435/f2f855f9-bc07-405d-8b0b-09b3da7e4f79)

## CONFIGURE Options

After setup you can change the refresh interval and add real-time source(s)

![image](https://github.com/vingerha/gtfs2/assets/44190435/03135ba3-e9ff-4fe6-a23b-bb1f0a44c6ea)

![image](https://github.com/vingerha/gtfs2/assets/44190435/11de0f3c-ac1b-4b4d-8712-38764dfc5bd4)

![image](https://github.com/vingerha/gtfs2/assets/44190435/5895e947-882d-444e-9259-e56d7d5e426a)





Sample of the entity and its attributes
```
arrival: "2023-11-04T09:42:29+00:00"
arrival: 2023-11-18T12:18:00+00:00
day: today
first: false
last: false
offset: 0
agency_agency_id: LE MET
agency_agency_name: LE MET'
agency_agency_url: https://lemet.fr
agency_agency_id: None
agency_agency_name: TAO (Orléans)
agency_agency_url: http://reseau-tao.fr/
agency_agency_timezone: Europe/Paris
agency_agency_lang: FR
agency_agency_phone: 0.800.00.29.38
agency_agency_fare_url: https://services.lemet.fr/fr/billetterie
agency_agency_email: [email protected]
origin_station_stop_id: "6010"
agency_agency_lang: fr
agency_agency_phone: 0800012000
agency_agency_fare_url: None
agency_agency_email: None
origin_station_stop_id: ORLEANS:StopArea:00026500
origin_station_stop_code: None
origin_station_stop_name: P+R WOIPPY
origin_station_stop_name: Gaston Galloux
origin_station_stop_desc: None
origin_station_stop_lat: "49.150349"
origin_station_stop_lon: "6.173323"
origin_station_stop_lat: 47.884827
origin_station_stop_lon: 1.924645
origin_station_zone_id: None
origin_station_stop_url: https://services.lemet.fr/fr/biv/arret/1627
origin_station_location_type: "0"
origin_station_stop_url: None
origin_station_location_type: 0
origin_station_parent_station: None
origin_station_stop_timezone: None
origin_station_wheelchair_boarding: "1"
origin_station_stop_timezone: Europe/Paris
origin_station_wheelchair_boarding: 0
origin_station_platform_code: None
origin_station_location_type_name: Station
origin_station_wheelchair_boarding_available: true
destination_station_stop_id: "6180"
origin_station_wheelchair_boarding_available: unknown
destination_station_stop_id: ORLEANS:StopArea:01001712
destination_station_stop_code: None
destination_station_stop_name: FELIX ALCAN
destination_station_stop_name: Gare d'Orléans - Quai E
destination_station_stop_desc: None
destination_station_stop_lat: "49.112572"
destination_station_stop_lon: "6.199158"
destination_station_stop_lat: 47.907085
destination_station_stop_lon: 1.90578
destination_station_zone_id: None
destination_station_stop_url: https://services.lemet.fr/fr/biv/arret/7324
destination_station_location_type: "0"
destination_station_stop_url: None
destination_station_location_type: 0
destination_station_parent_station: None
destination_station_stop_timezone: None
destination_station_wheelchair_boarding: "1"
destination_station_stop_timezone: Europe/Paris
destination_station_wheelchair_boarding: 0
destination_station_platform_code: None
destination_station_location_type_name: Station
destination_station_wheelchair_boarding_available: true
route_route_id: A-98
route_agency_id: LE MET
route_route_short_name: MA
route_route_long_name: METTIS A
destination_station_wheelchair_boarding_available: unknown
route_route_id: ORLEANS:Line:40
route_agency_id: None
route_route_short_name: 40
route_route_long_name: GARE ORLEANS - PETITE MERIE
route_route_desc: None
route_route_type: "3"
route_route_type: 3
route_route_url: None
route_route_color: F0980C
route_route_text_color: FFFFFF
route_route_color: 24A472
route_route_text_color: 000000
route_type_name: Bus
trip_route_id: A-98
trip_service_id: HIV2324-Sam_Sp23-Samedi-21
trip_trip_id: 1281546-HIV2324-Sam_Sp23-Samedi-21
trip_trip_headsign: MA - BORNY
trip_route_id: ORLEANS:Line:40
trip_service_id: chouette:TimeTable:4f12e6e5-93ca-4af2-b493-0858f5c73e39:LOC
trip_trip_id: ORLEANS:VehicleJourney:40_A_56_16_4002_6_124300
trip_trip_headsign: None
trip_trip_short_name: None
trip_direction_id: "0"
trip_block_id: "196205"
trip_shape_id: A0014
trip_wheelchair_accessible: "1"
trip_bikes_allowed: "2"
trip_bikes_allowed_state: false
trip_wheelchair_access_available: true
origin_stop_arrival_time: "2023-11-04 10:16:00"
origin_stop_departure_time: "2023-11-04 10:16:00"
origin_stop_drop_off_type: 0
trip_direction_id: 0
trip_block_id: None
trip_shape_id: PME-CNY-POSC-GARE
trip_wheelchair_accessible: None
trip_bikes_allowed: None
trip_bikes_allowed_state: unknown
trip_wheelchair_access_available: unknown
origin_stop_arrival_time: 2023-11-18T12:09:05+00:00
origin_stop_departure_time: 2023-11-18T12:09:05+00:00
origin_stop_pickup_type: 0
origin_stop_sequence: 1
origin_stop_drop_off_type_state: Regular
origin_stop_sequence: 17
origin_stop_drop_off_type_state: unknown
origin_stop_pickup_type_state: Regular
origin_stop_timepoint_exact: true
destination_stop_arrival_time: "2023-11-04 10:42:29"
destination_stop_departure_time: "2023-11-04 10:42:29"
destination_stop_drop_off_type: 0
destination_stop_arrival_time: 2023-11-18T12:18:00+00:00
destination_stop_departure_time: 2023-11-18T12:18:00+00:00
destination_stop_pickup_type: 0
destination_stop_sequence: 19
destination_stop_drop_off_type_state: Regular
destination_stop_sequence: 23
destination_stop_drop_off_type_state: unknown
destination_stop_pickup_type_state: Regular
destination_stop_timepoint_exact: true
next_departures:
- "2023-11-04 10:16:00"
- "2023-11-04 10:31:00"
- "2023-11-04 10:46:00"
- "2023-11-04 11:01:00"
- "2023-11-04 11:16:00"
- "2023-11-04 11:31:00"
- "2023-11-04 11:46:00"
- "2023-11-04 12:01:00"
- "2023-11-04 12:16:00"
- "2023-11-04 12:31:00"
next_departures_lines:
- 2023-11-04 10:16:00 (METTIS A)
- 2023-11-04 10:31:00 (METTIS A)
- 2023-11-04 10:46:00 (METTIS A)
- 2023-11-04 11:01:00 (METTIS A)
- 2023-11-04 11:16:00 (METTIS A)
- 2023-11-04 11:31:00 (METTIS A)
- 2023-11-04 11:46:00 (METTIS A)
- 2023-11-04 12:01:00 (METTIS A)
- 2023-11-04 12:16:00 (METTIS A)
- 2023-11-04 12:31:00 (METTIS A)
updated_at: "2023-11-04T10:07:07.085514"
attribution: LE MET'
next_departures: 2023-11-18T12:09:05+00:00, 2023-11-18T12:39:05+00:00, 2023-11-18T13:10:05+00:00, 2023-11-18T13:40:05+00:00, 2023-11-18T14:10:05+00:00, 2023-11-18T14:40:05+00:00, 2023-11-18T15:11:05+00:00, 2023-11-18T15:41:05+00:00, 2023-11-18T16:12:05+00:00, 2023-11-18T16:42:05+00:00
next_departures_lines: 2023-11-18T12:09:05+00:00 (GARE ORLEANS - PETITE MERIE), 2023-11-18T12:39:05+00:00 (GARE ORLEANS - PETITE MERIE), 2023-11-18T13:10:05+00:00 (GARE ORLEANS - PETITE MERIE), 2023-11-18T13:40:05+00:00 (GARE ORLEANS - PETITE MERIE), 2023-11-18T14:10:05+00:00 (GARE ORLEANS - PETITE MERIE), 2023-11-18T14:40:05+00:00 (GARE ORLEANS - PETITE MERIE), 2023-11-18T15:11:05+00:00 (GARE ORLEANS - PETITE MERIE), 2023-11-18T15:41:05+00:00 (GARE ORLEANS - PETITE MERIE), 2023-11-18T16:12:05+00:00 (GARE ORLEANS - PETITE MERIE), 2023-11-18T16:42:05+00:00 (GARE ORLEANS - PETITE MERIE)
next_departures_headsign: 2023-11-18T12:09:05+00:00 (None), 2023-11-18T12:39:05+00:00 (None), 2023-11-18T13:10:05+00:00 (None), 2023-11-18T13:40:05+00:00 (None), 2023-11-18T14:10:05+00:00 (None), 2023-11-18T14:40:05+00:00 (None), 2023-11-18T15:11:05+00:00 (None), 2023-11-18T15:41:05+00:00 (None), 2023-11-18T16:12:05+00:00 (None), 2023-11-18T16:42:05+00:00 (None)
gtfs_updated_at: 2023-11-18T11:38:52.654949+00:00
gtfs_rt_updated_at: 2023-11-18T11:40:59.832457+00:00
next_departure_realtime: 2023-11-18T12:09:30+00:00
latitude:
longitude:
attribution: TAO (Orléans)
device_class: timestamp
icon: mdi:bus
friendly_name: MyRouteInMetz
friendly_name: Orleans 40 outbound
```


Expand Down

0 comments on commit 219d558

Please sign in to comment.