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_metadata
accepts aunit_class
that points to the unit converter used for unit conversions. If there is no compatible unit converter,unit_class
should be set tonull
. Not specifying theunit_class
is deprecated and will stop working in Home Assistant Core 2026.11. - The
metadata
object included in the WS commandrecorder/import_statistics
accepts aunit_class
that points to the unit converter used for unit conversions. If there is no compatible unit converter,unit_class
should be set tonull
. Not specifying theunit_class
is deprecated and will stop working in Home Assistant Core 2026.11. - The
metadata
object included in the WS commandrecorder/import_statistics
accepts amean_type
that specifies the type of mean (0
for no mean,1
for arithmetic mean, or2
for circular mean). Themean_type
replaces the bool flaghas_mean
. Not specifying themean_type
is deprecated and will stop working in Home Assistant Core 2026.11. - The items in the response to the WS commands
recorder/list_statistic_ids
andrecorder/get_statistics_metadata
havemean_type
andunit_class
. - The
has_mean
in the items in the response to the WS commandsrecorder/list_statistic_ids
andrecorder/get_statistics_metadata
is 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_metadata
accepts anew_unit_class
that points to the unit converter used for unit conversions. If there is no compatible unit converter,new_unit_class
should be set toNone
. Not specifying thenew_unit_class
is deprecated and will stop working in Home Assistant Core 2025.11. - The metadata object passed to the functions
async_import_statistics
andasync_add_external_statistics
accepts aunit_class
that points to the unit converter used for unit conversions. If there is no compatible unit converter,unit_class
should be set toNone
. Not specifying theunit_class
is deprecated and will stop working in Home Assistant Core 2025.11. - The metadata object passed to the functions
async_import_statistics
andasync_add_external_statistics
accepts amean_type
of typeStatisticMeanType
that specifies the type of mean (NONE
,ARITHMETIC
, orCIRCULAR
). Themean_type
replaces the bool flaghas_mean
. Not specifying themean_type
is deprecated and will stop working in Home Assistant Core 2026.11. - The items in the return value of the function
async_list_statistic_ids
havemean_type
andunit_class
. - The
has_mean
in the items in the return value of the functionasync_list_statistic_ids
is deprecated and will be removed in Home Assistant Core 2026.11.