Skip to content

Migrate from deprecated /history to /calendar_history API#101

Closed
gbassaragh wants to merge 1 commit intoMikeBishop:masterfrom
gbassaragh:fix/calendar-history-api
Closed

Migrate from deprecated /history to /calendar_history API#101
gbassaragh wants to merge 1 commit intoMikeBishop:masterfrom
gbassaragh:fix/calendar-history-api

Conversation

@gbassaragh
Copy link

Summary

Tesla has deprecated the /history endpoint (returns HTTP 410) and now requires the /calendar_history endpoint with explicit date parameters.

The old /history endpoint was returning:

{"error":"No longer supported: Use /v3/energy_site/energy_history instead","error_description":""}

Changes

  • Added getCalendarHistoryDates() helper function for generating UTC date parameters
  • Updated doTeslaApiGetEnergy to use /calendar_history
  • Updated doTeslaApiGetPowerHistory to use /calendar_history
  • Updated doTeslaApiGetBackupHistory to use /calendar_history
  • Updated doTeslaApiGetSelfConsumption to use /calendar_history

All endpoints now include the required start_date, end_date, and time_zone parameters in ISO 8601 format.

Testing

Tested with Tesla Owner API - all endpoints now return time_series data successfully:

  • kind=energy - returns energy consumption data
  • kind=power - returns power flow data
  • kind=self_consumption - returns self-consumption metrics
  • kind=backup - returns backup event history

Energy history charts now display correctly in the MagicMirror module.

Related

This addresses the Tesla API deprecation that occurred in late 2024, where the legacy /history endpoint was retired in favor of the Fleet API's /calendar_history endpoint.

Tesla has deprecated the /history endpoint (returns HTTP 410) and now
requires the /calendar_history endpoint with explicit date parameters.

Changes:
- Add getCalendarHistoryDates() helper function for UTC date generation
- Update doTeslaApiGetEnergy to use /calendar_history
- Update doTeslaApiGetPowerHistory to use /calendar_history
- Update doTeslaApiGetBackupHistory to use /calendar_history
- Update doTeslaApiGetSelfConsumption to use /calendar_history

All endpoints now include required start_date, end_date, and time_zone
parameters in ISO 8601 format.

Fixes energy history charts not displaying due to API deprecation.
@MikeBishop
Copy link
Owner

As you presumably found after this (leading to #102), there's a good bit of data handling fixes to be done on top of the obvious changes.

@MikeBishop MikeBishop closed this Dec 29, 2025
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

Comments