Changes to the recorder statistics API
· 3 min read
The Python and WS APIs for injecting and modifying statistics have changed.
The following changes have been made to the WS API:
- The WS command
recorder/update_statistics_metadataaccepts aunit_classthat points to the unit converter used for unit conversions. If there is no compatible unit converter,unit_classshould be set tonull. Not specifying theunit_classis deprecated and will stop working in Home Assistant Core 2026.11. - The
metadataobject included in the WS commandrecorder/import_statisticsaccepts aunit_classthat points to the unit converter used for unit conversions. If there is no compatible unit converter,unit_classshould be set tonull. Not specifying theunit_classis deprecated and will stop working in Home Assistant Core 2026.11. - The
metadataobject included in the WS commandrecorder/import_statisticsaccepts amean_typethat specifies the type of mean (0for no mean,1for arithmetic mean, or2for circular mean). Themean_typereplaces the bool flaghas_mean. Not specifying themean_typeis deprecated and will stop working in Home Assistant Core 2026.11. - The items in the response to the WS commands
recorder/list_statistic_idsandrecorder/get_statistics_metadatahavemean_typeandunit_class. - The
has_meanin the items in the response to the WS commandsrecorder/list_statistic_idsandrecorder/get_statistics_metadatais deprecated and will be removed in Home Assistant Core 2026.11.
The following changes have been made to the Python API:
- The function
async_update_statistics_metadataaccepts anew_unit_classthat points to the unit converter used for unit conversions. If there is no compatible unit converter,new_unit_classshould be set toNone. Not specifying thenew_unit_classis deprecated and will stop working in Home Assistant Core 2025.11. - The metadata object passed to the functions
async_import_statisticsandasync_add_external_statisticsaccepts aunit_classthat points to the unit converter used for unit conversions. If there is no compatible unit converter,unit_classshould be set toNone. Not specifying theunit_classis deprecated and will stop working in Home Assistant Core 2025.11. - The metadata object passed to the functions
async_import_statisticsandasync_add_external_statisticsaccepts amean_typeof typeStatisticMeanTypethat specifies the type of mean (NONE,ARITHMETIC, orCIRCULAR). Themean_typereplaces the bool flaghas_mean. Not specifying themean_typeis deprecated and will stop working in Home Assistant Core 2026.11. - The items in the return value of the function
async_list_statistic_idshavemean_typeandunit_class. - The
has_meanin the items in the return value of the functionasync_list_statistic_idsis deprecated and will be removed in Home Assistant Core 2026.11.