tomhollander / PowerwallCompanion

Windows UWP app for monitoring your Tesla Powerwall 2 battery
9 stars 7 forks source link

Version 4.7: No Load (Consumer?) data in download for current or previous Day #11

Closed peppersass closed 9 months ago

peppersass commented 9 months ago

I much appreciate being able to download Day data by date. Thank you!

However, the Load data is missing from the Day download. My program that processes the Day data requires that field. Judging from the changes to the Week, Month and Year data, I think they're calling Load data Consumer data, but I'm not sure. I haven't checked your code yet, but maybe that field was inadvertently omitted?

It would be great if you could put the Load data in the fifth column (after grid_power), as it was before, but if that's not possible I can modify my program to deal with different versions of the file format.

The data downloaded for Week, Month and Year has changed a lot, too. It will require additional effort on my part to map the data into what my program expects.

Since 3.6 can still get the data in the old format, I'm assuming it's still available from Tesla that way. It would be really great if you could add an option to download data for all periods in the format supplied by version 3.6.

tomhollander commented 9 months ago

Hey, sorry for the breaking changes. I made major changes to the app to support historical data downloads, and I decided it would be best to return the raw data from the Tesla API response rather than (re)inventing my own. The home/load data is not returned by the API, but it's just the sum of all the other values (positive and negative).

As a compromise - how about I keep returning whatever the API does, but I'll append the load data in an additional field?

peppersass commented 9 months ago

Ah. I didn't look at the previous code closely enough to see that you were massaging the data. The Tesla app does, too. In fact, they lose a little precision by rounding the values to 0.1 kWh. That's why I prefer your version of the data.

Also, my version uses some fields from your Year data to figure out what it would cost in a given month if I didn't have the batteries or if I switch to our town energy cooperative, which has lower energy rates (currently the answer is no, because I'll get paid less for exported power and that outweighs the energy savings.)

No need to add the Load data unless you want to. My program uses the header to distinguish different versions of the file/data format (much of my historical data was downloaded by the Tesla app.) As long as it has to do that, it can identify the new format and do the addition to get the Load data. I see that adding the "consumer_energy_imported_from" columns for solar, battery and grid in the Year data will give me the load usage.

Actually, I'll only be using 4.7 to fill in gaps. I run a modified copy of 3.6 as a scheduled daily task on a fanless nano PC to capture the previous day's data. I modified it to download "Yesterday" if there's a file called "TeslaScheduled.txt" in the LocalState folder, then terminate. Adding a command line option would have been cleaner, but not easy with UWP apps. Works well, but every now and then it fails to run for some reason or another (like a Windows update reboot) and I have to use the Tesla app to capture the missed days. With 4.7 I can get the raw data now. Not sure it's worth adding my mod to 4.7, but will if I have some time on my hands.