Skip to content

fix: add mean_type to async_import_statistics before HA 2026.11 cutoff #22

Description

@jnctech

Problem

HA 2026.11 will break our long-term statistics imports. The following warning appears in the HA log on every startup (3 occurrences — CGM, IOB, basal):

WARNING [homeassistant.helpers.frame] Detected that custom integration 'carelink' doesn't specify
mean_type when calling async_import_statistics at custom_components/carelink/__init__.py,
line 1997: async_import_statistics(self.hass, cgm_meta, cgm_stats).
This will stop working in Home Assistant 2026.11, please create a bug report.

Affected code

__init__.py — three async_import_statistics calls around lines 1997, 2012, 2027:

async_import_statistics(self.hass, cgm_meta, cgm_stats)   # line 1997
async_import_statistics(self.hass, iob_meta, iob_stats)   # line 2012
async_import_statistics(self.hass, basal_meta, basal_stats)  # line 2027

Fix required

Add mean_type=StatisticMeanType.ARITHMETIC to all three calls:

from homeassistant.components.recorder.statistics import StatisticMeanType

async_import_statistics(self.hass, cgm_meta, cgm_stats, mean_type=StatisticMeanType.ARITHMETIC)
async_import_statistics(self.hass, iob_meta, iob_stats, mean_type=StatisticMeanType.ARITHMETIC)
async_import_statistics(self.hass, basal_meta, basal_stats, mean_type=StatisticMeanType.ARITHMETIC)

Blocker

mean_type parameter is not yet available in the HA API as of 2026.2/2026.3 (coming in HA 2026.11). We cannot add this fix until HA 2026.11 ships (approx. November 2026).

Action

  • Monitor HA 2026.11 release notes for StatisticMeanType availability
  • Apply the fix before HA 2026.11 goes stable
  • Update tests/ to cover the new parameter

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions