tesladdicts / testatus

Python suite to access the Tesla JSON API, pollers and log via the API, parse the log, rpc, etc
MIT License
12 stars 2 forks source link

Plan for report generation #4

Open pmendes opened 5 years ago

pmendes commented 5 years ago

I'm planning writing several short programs that create specific reports. Each of these will be able to output the report in several formats; right now I am implementing simple text (console that can be piped out), html, pdf, and xlsx. Any others desired?

I am currently working on the first one for charging sessions. It processes data from the previous n days (a command line parameter). Could eventually also make it between two specific dates (currently the end date is now()). It will display details of the charging sessions, including temperatures, location, etc. It will also optionally include plots of the temperature and charge as the session progresses.

For trips I am thinking of including maps, using OpenStreetMap.

I am also planning to add another SQL table for locations (useful to name charging locations rather than use coordinates, eg charging stations and superchargers). The data for this is available, and so are appropriate libraries, so it should be all fairly easy to do.

Any comments on these plans are very welcome!

SethRobertson commented 5 years ago

For any graphical reports, please produce PNG/JPG

One interesting graph would be battery capacity over time/miles (my analytics already generates battery capacity for each charge session, though I don't think it is a python function--I could correct that). Even better if there was an option to have battery capacity by temperature band. Or perhaps a scatter-plot with color being a temperature.

For the SQL location table to be interesting, I'd recommend autogenerating the location table (using a clustering algorithm to group different parking spots) and then annotate them with whether charging happened at that location. OpenStreetMap has an API (Nominatim) to generate an address from a GPS location--then you can auto-label them and have a appearance count. People who care can then make aliases (or as you point out, autoalias for charging locations). Maybe a link to a plugshare page for the location if appropriate.

For clustering, stackexchange has some suggestions. I'm sure they are pretty much all overkill for our use case since generally parking locations will be pretty disjoint. Pretty much the only time you would need to go to something this sophisticated would be to cluster street parking in some cases with smeared parking locations and NOT cluster strip mall parking in front of different stores. https://datascience.stackexchange.com/questions/761/clustering-geo-location-coordinates-lat-long-pairs I'm sure you will be displeased with the lack of consensus.

pmendes commented 5 years ago

I think those are all great ideas. I was already planning to use Nominatim and automatically add names from there (users can then change them if needed). Clustering is a good idea and I though of that but first using something basic, then we can add more sophistication as you suggested.

I've started using jinja2 for report templates. Currently only text and html, pdf will be the next (based on the html).

I will add plots in png built with matplotlib. The first planned one is for temperatures and charging rates for each charging session.