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

RFC: Basic NOBIL implementation #363

Open
wants to merge 27 commits into
base: master
Choose a base branch
from
Open

RFC: Basic NOBIL implementation #363

wants to merge 27 commits into from

Conversation

robho
Copy link
Contributor

@robho robho commented Nov 6, 2024

This adds a NOBIL data source. Data is available in Denmark, Finland, Iceland, Norway and Sweden and the data is collected both from operators via OCPI and contributed by the public.

This is a draft implementation where some functionality is missing. I'm interested in hearing if this is of interest, and if so, what should I fix/work on going forward?

Known problems / missing features:

  • Not all charger data is exposed in the app (location (near restaurant/shopping/...), payment methods, ...)
  • No filters are implemented
  • Chargeprice connection missing
  • Does Android Auto work? Not yet tested
  • When a charging point is removed in nobil it doesn't disappear in the UI (a cache clear is needed). Maybe a generic evmap bug?
  • The code could use some cleanup from someone with Android development experience

@robho robho force-pushed the nobil branch 3 times, most recently from 80cdd5e to d0c19e3 Compare November 7, 2024 21:14
@johan12345
Copy link
Collaborator

johan12345 commented Nov 7, 2024

Very nice, thanks a lot! I'll try to find some time in the weekend to try it out and provide some help with code cleanup.

Not all charger data is exposed in the app (photo, location (near restaurant/shopping/...), payment methods, ...)

Yeah, if there are properties that don't fit into EVMap's data structure we can think about adding new fields or expanding existing ones where it is useful. For payment methods, we have the chargecards structure (used by GoingElectric, but a bit more complex than necessary for what NOBIL provides) or we could just put it into the cost.description for now). For location, the most similar field in GoingElectric would be "category", but that is not exposed through their API, so I haven't added it so far. amenities might also work, though that is usually a slightly longer text description in GoingElectric.

No filters are implemented

As previously mentioned, I guess all the filters would have to be implemented locally, as the Nobil API doesn't really have server-side filtering abilities, right? That should be possible (just like the min_connectors filter for GE and OCM), but in the longer term the better solution is probably to first download all chargers into the local DB (which is a capability I'm implementing for #290) and perform filtering there.

Chargeprice connection missing

Chargeprice currently only support GoingElectric and OpenChargeMap unfortunately. And by now they have also created their own separate database of charging stations aggregated from different sources, so from what I heard they are not so interested in fixing issues with their adapters for GE and OCM, let alone adding new ones 🫤.
Also, there is #320 - so I am not sure how long the native Chargeprice integration in EVMap will stay or whether I will have to try to build an alternative at some point.

Does Android Auto work? Not yet tested

Likely yes, I can test that as well.

When a charging point is removed in nobil it doesn't disappear in the UI (a cache clear is needed). Maybe a generic evmap bug?

True, that is probably a general bug - for GoingElectric it's not so relevant as we are only allowed to cache the data for 24h anyway. But yeah, it probably also applies to OpenChargeMap. Let's track that in a separate issue.

// 24: Open 24h
if (chargerStationAttributes.st["24"]?.attrTrans == "Yes") OpeningHours(twentyfourSeven = true, null, null) else null,
// 7: Parking fee
if (chargerStationAttributes.st["7"]?.attrTrans == "No") Cost(freeparking = true) else null,
Copy link
Collaborator

Choose a reason for hiding this comment

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

If the attribute is set to "Yes" (i.e. known to have a parking fee), you could also set it to Cost(freeparking = false). It should only be set to null if the parking fee is not known.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Other fields from Nobil that might be relevant to the Cost - maybe these could be used to generate a description?

  • Time limit
  • Accessibility (does Open mean freecharging?)
  • Payment Method

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Looks like I either add freecharging and freeparking or descriptions. If I set freecharging and freeparking then EVMap creates a text string for me and ignores the descriptions. Right?

Copy link
Collaborator

Choose a reason for hiding this comment

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

No, you can also set both - then freecharging/freeparking will be shown in the first line and the description as a smaller text below.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added some information to the Cost description:

Accepted payment methods: Bank card, Charging card

I looked into "Time limit" and "Accessibility", but they were not reliable and consistent.

null,
Instant.now(),
true
)
Copy link
Collaborator

@johan12345 johan12345 Nov 9, 2024

Choose a reason for hiding this comment

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

Other than what we already have, I think the Availability attribute ( Public/Visitors/Employees/By Appointment/Residents) would be great to add and also have as a filter (at least as a binary filter - only publicly accessible or all)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

See 70953af. What do you think?

I kept the name "availability" although it could perhaps be confusing when the realtime data code refers to "availability" also.

app/src/main/java/net/vonforst/evmap/api/nobil/NobilApi.kt Outdated Show resolved Hide resolved
@robho
Copy link
Contributor Author

robho commented Nov 9, 2024

Regarding filtering..

in the longer term the better solution is probably to first download all chargers into the local DB (which is a capability I'm implementing for #290) and perform filtering there.

Is your idea to replace the on-demand-loading with a full data fetch or are you thinking of having some combination of the two?

The nobil data is ~130 Mbytes today (up ~6 Mbytes in ~2 months). This is uncompressed data, I haven't checked if the server can compresss data and what the compressed size is. I think I would prefer to use on-demand loading most of the time, but it would be valuable to have the possibility to cache all data when needed (no mobile connection or high mobile roaming prices, ...).

Is the problem that you see with local filters that they need to fetch data for chargers that are uninteresting? Ie unnecessary network traffic and data processing? Are those "unnecessary" downloads cached even if they are not used?

@johan12345
Copy link
Collaborator

johan12345 commented Nov 12, 2024

The nobil data is ~130 Mbytes today (up ~6 Mbytes in ~2 months). This is uncompressed data, I haven't checked if the server can compresss data and what the compressed size is.

Gzip usually helps quite a lot with JSON data, and the Nobil server does seem to support it. According to

curl --compressed -so /dev/null "https://www.nobil.no/api/server/datadump.php?apikey=<key>&fromdate=2005-01-01&format=json" -w '%{size_download}'

the download size is pretty small at just ~5 MB. Of course it might occupy a bit more space in the local database (and from my experience with the implementation for OSM, parsing the JSON and inserting chargers into the DB also takes much more time than the download itself).

Is your idea to replace the on-demand-loading with a full data fetch or are you thinking of having some combination of the two?

In general, EVMap will continue to support both. So we could offer both options for Nobil. On the other hand, with such a small download size, there's not much of a downside to storing it all locally - might also reduce the load on Nobil's servers in the long term.

Is the problem that you see with local filters that they need to fetch data for chargers that are uninteresting? Ie unnecessary network traffic and data processing?

Yeah. I think the data processing (JSON parsing into Kotlin objects, then filtering) is usually the main bottleneck when loading a large map region with thousands or even ten-thousands of chargers - server-side filtering and even server-side clustering makes it a lot faster for GoingElectric where that is supported.

Also, depending on what filters we implement, there might be some filters where we can only determine the available options by iterating through the whole dataset once (e.g., the network filter mentioned in the comments) and then storing that as ReferenceData.

Are those "unnecessary" downloads cached even if they are not used?

not at the moment, because local filtering happens inside the API implementation

@johan12345 johan12345 added this to the 2.0.0 milestone Nov 24, 2024
I think this is more in line with how other non-existent parameters are handled.

Also added some code to merge evseIds when merging Chargepoints.
robho added 2 commits December 1, 2024 21:45
Nobil has no suitable sites to individual charging stations so url needs
to be optional and then we use dataSourceUrl instead in "data source button".
URLEncoder.encode() encodes ' ' as '+' and that's not handled by
all email apps. Uri.encode() uses "%20" for ' '.
robho added 2 commits December 4, 2024 22:58
In the charger details screen, set the share menu item's visibility in the
same way as the favorite menu item's state is set.
robho added 7 commits December 9, 2024 21:43
All valid nobil images are [0-9]+.(jpg|png), all other file name
variants should be discarded (such as "coming soon").
In nobil there's a connector type named "Type 2 + Schuko". If this means
that both a type 2 connector and a schuko connector is available I think
it makes more sense to parse this like a type 2 connector rather than a
schuko connector since most people want type 2 connectors.

A new EVMap connector type could be created, but it seems to add little
value since "Type 2 + Schuko" is only used by a single charging station
in nobil, ie the use would be extremely limited.
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.

2 participants