Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add provider free2move / free2move_stuttgart #194

Merged
merged 20 commits into from
Dec 18, 2024
Merged

Conversation

hbruch
Copy link
Collaborator

@hbruch hbruch commented Dec 8, 2024

This PR adds Free2moveProvider.

NOTE: the generated feed publishes free floating vehicles using the original vehicle identifiers (VIN) as bike_ids and in rental_uris. In consequence, it does not comply to the GBFS spec, which requires that

The bike_id identifier MUST be rotated to a random string after each trip to protect user privacy (as of v2.0). Use of persistent vehicle IDs poses a threat to user privacy. The bike_id identifier SHOULD only be rotated once per trip.

This feed must not be published openly without handling of this issue.

@hbruch hbruch requested a review from derhuerst December 8, 2024 09:40
@hbruch hbruch requested a review from the-infinity December 9, 2024 08:29
Copy link
Member

@derhuerst derhuerst left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to tweak the geofencing_zones.json docs and the caching implementation. Otherwise just small comments.

docs/mappings/free2move_gbfs_2.3_mapping.md Outdated Show resolved Hide resolved
docs/mappings/free2move_gbfs_2.3_mapping.md Outdated Show resolved Hide resolved
docs/mappings/free2move_gbfs_2.3_mapping.md Show resolved Hide resolved
docs/mappings/free2move_gbfs_2.3_mapping.md Outdated Show resolved Hide resolved
docs/mappings/free2move_gbfs_2.3_mapping.md Outdated Show resolved Hide resolved
x2gbfs/providers/free2move.py Show resolved Hide resolved
x2gbfs/providers/free2move.py Show resolved Hide resolved
# We build dicts with VINs as key to merge on them
cached_vehicles_map = {v['vin']: v for v in cached_response.get('vehicles', {})}
delta_vehicles_map = {v['vin']: v for v in delta_response.get('vehicles', {})}
merged_vehicles_map = cached_vehicles_map | delta_vehicles_map
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does delta_response ever contain information that a vehicle is not available (as in "is not rentable", not as in "is currently rented") anymore? If it does, how would we take that information into account when merging?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The API publishes freeForRental, so unavailable vehicles should be published in the delta. Using only delta feeds nvertheless could result in "ghost cars", which are not published any longer. Performing a full update every hour should limit this at least.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using only delta feeds nvertheless could result in "ghost cars", which are not published any longer. Performing a full update every hour should limit this at least.

I recommend adding this information to the docs.

headers: Optional[dict[str, str]] = None,
json: Optional[Dict] = None,
timeout: int = 5,
user_agent: str = 'x2gbfs +https://github.com/mobidata-bw/',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shall we make this configurable via an environment variable?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this should become a proper PR

x2gbfs/providers/free2move.py Show resolved Hide resolved
@hbruch hbruch requested a review from derhuerst December 9, 2024 16:21
@hbruch hbruch requested a review from derhuerst December 11, 2024 21:31
Copy link
Member

@ThorstenFroehlinghaus ThorstenFroehlinghaus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This converter works for all locations, right? I need to clarify, if we can provide other locations than stuttgart.

`vehicle_image` | `row['imageUrl']`, `{density}` is set to `2x`, as only one image may be specified.
`make` | extracted from `row['buildSeries']` and mapped in the code.
`model` | extracted from `row['buildSeries']` and mapped in the code.
`color` | `row['primaryColor']` mapped to `weiß`, `silber`, `schwarz` or `grau`. In case no mapping is defined, we return the last part of the `imageUrl`, as this seems to contain the color string (in English). If no `imageUrl` is provided, we return `unbekannt`.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to introduce a value 'unbekannt'? I suggest to omit the color attribute if no color information is available.

`vehicle_type_id` | see section vehicle_types
`last_reported` | curent time
`current_range_meters` | `row['remainingRange']`, if set
`current_fuel_percent` | `row['fuelLevel'] / 100.0`, or `.25` if unset

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need to define a default value? current_fuel_percent is optional.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to documentation, fuelLevel is not optional and should provided for every vehicle. I remove the default handling.

@hbruch
Copy link
Collaborator Author

hbruch commented Dec 13, 2024

This converter works for all locations, right? I need to clarify, if we can provide other locations than stuttgart.

It should. But note that other areas may use different buildSeries.

@hbruch hbruch merged commit 8de36d5 into main Dec 18, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants