|
| 1 | +--- |
| 2 | +author: Erik Montnemery |
| 3 | +authorURL: https://github.com/emontnemery |
| 4 | +title: "Changes to long term statistics APIs" |
| 5 | +--- |
| 6 | + |
| 7 | +Some changes have been made to the long-term statistics-related APIs to reduce response size and database load. |
| 8 | + |
| 9 | +The changes are implemented in [this PR](https://github.com/home-assistant/core/pull/82131). |
| 10 | + |
| 11 | +This affects authors of code calling the following WS APIs: |
| 12 | + - `recorder/statistics_during_period` |
| 13 | + - A new optional parameter `types` has been added, which allows providing a list of statistics characteristics to include in the response. Possible values are: `"last_reset"`, `"max"`, `"mean"`, `"min"`, `"state"`, `"sum"` |
| 14 | + - Timestamps `start`, `end` and `last_reset` are now an integer number of ms since the UNIX epoch instead of ISO-formatted strings. The new format means the timestamps can be passed directly to js `Date()` constructor. |
| 15 | + - The `statistic_id` is no longer repeated for each list item in the returned map. This was not used because the return type is a map, keyed by `statistic_id`. |
| 16 | + |
| 17 | +This affects authors of code calling the following Python APIs: |
| 18 | +- `homeassistant.recorder.statistics.get_last_short_term_statistics` |
| 19 | + - A new parameter `types` has been added, which allows providing a set of statistics characteristics to include in the response. Possible values are: `"last_reset"`, `"max"`, `"mean"`, `"min"`, `"state"`, `"sum"` |
| 20 | + - Timestamps `start`, `end` and `last_reset` are now an `datetime` objects instead of ISO-formatted strings. |
| 21 | + - The `statistic_id` is no longer repeated for each list item in the returned map. This was not used because the return type is a map, keyed by `statistic_id`. |
| 22 | +- `homeassistant.recorder.statistics.get_latest_short_term_statistics` |
| 23 | + - A new parameter `types` has been added, which allows providing a set of statistics characteristics to include in the response. Possible values are: `"last_reset"`, `"max"`, `"mean"`, `"min"`, `"state"`, `"sum"` |
| 24 | + - Timestamps `start`, `end` and `last_reset` are now an `datetime` objects instead of ISO-formatted strings. |
| 25 | + - The `statistic_id` is no longer repeated for each list item in the returned map. This was not used because the return type is a map, keyed by `statistic_id`. |
| 26 | +- `homeassistant.recorder.statistics.statistics_during_period` |
| 27 | + - A new parameter `types` has been added, which allows providing a set of statistics characteristics to include in the response. Possible values are: `"last_reset"`, `"max"`, `"mean"`, `"min"`, `"state"`, `"sum"` |
| 28 | + - Timestamps `start`, `end` and `last_reset` are now an `datetime` objects instead of ISO-formatted strings. |
| 29 | + - The `statistic_id` is no longer repeated for each list item in the returned map. This was not used because the return type is a map, keyed by `statistic_id`. |
0 commit comments