Skip to content

Sense Integration Skips 12–1 AM Data Due to UTC Misalignment #149492

Description

@jcefoli

The problem

When using the Sense integration, the data point for 12–1 AM is missing entirely, leading to an inaccurate daily total. This issue was previously reported in #66077, which was closed without a fix. However, the problem still persists in the latest version.

In the screenshot below, you will see data missing for the 12am-1am range and then everything is shifted an hour later when it should not be.

Image

After analyzing both the Sense Python library and the Home Assistant integration codebase, it seems like the issue stems from how timestamps are handled:

  • In SenseTrendsSensor, the value is fetched using:

    return round(self._gateway.get_stat(self._scale, self._variant_id), 1)
  • The start time for trend data is defined by:

    def last_reset(self) -> datetime | None:
        if self._attr_state_class == SensorStateClass.TOTAL:
            return self._gateway.trend_start(self._scale)
        return None
  • get_stat and trend_start both rely on UTC datetimes and do not perform any timezone conversion to local midnight.

  • Specifically, trend_start parses the "start" field using ciso8601.parse_datetime, which returns a UTC datetime unless a timezone is explicitly included.

  • get_stat retrieves the corresponding value for a given scale and key but does not adjust the timestamp or perform any alignment with local time.

If the Sense API data begins at UTC midnight and Home Assistant expects statistics to align to local midnight, the first hour (12–1 AM local) could be skipped, resulting in the observed data gap. Further investigation may be required to confirm how the "start" field is interpreted by Home Assistant and whether a timezone conversion is performed.

What version of Home Assistant Core has the issue?

core-2025.7.3

What was the last working version of Home Assistant Core?

This never worked

What type of installation are you running?

Home Assistant Core

Integration causing the issue

sense

Link to integration documentation on our website

https://www.home-assistant.io/integrations/sense/

Diagnostics information

No response

Example YAML snippet

Anything in the logs that might be useful for us?

Additional information

No response

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

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions