#Sense Integration Data Points Incorrect

1 messages · Page 1 of 1 (latest)

valid trail
#

I was wondering if anyone here could reopen a Github issue where Sense data points are off by one hour.

The closed and never-fixed issue is the following: https://github.com/home-assistant/core/issues/66077

I have more information on this and believe it could be solved. I'm not a python dev, but wanted to discuss this

GitHub

The problem When using the sense intgration the data points are off by an hour. The data from 12 to 1 am shows up in 1 to 2 am causing all day to be off and then it misses the final value from 11PM...

#

In SenseTrendsSensor, the value is fetched using:

return round(self._gateway.get_stat(self._scale, self._variant_id), 1)

The start time for the trend is provided by:

def last_reset(self) -> datetime | None:
    if self._attr_state_class == SensorStateClass.TOTAL:
        return self._gateway.trend_start(self._scale)
    return None

If get_stat or trend_start does not correctly align with the start of the day (midnight), or if the Sense API returns data with a timezone offset or missing the first hour, the resulting statistics in Home Assistant will not cover 12am–1am.

In investigating the sense pypy library,

trend_start parses the "start" field from the trend data using ciso8601.parse_datetime, which returns a UTC datetime unless the string includes a timezone.

get_stat retrieves a value from the trend data for a given scale and key, but does not perform any timezone conversion or alignment to local midnight.

Both methods use UTC datetimes and do not align to local midnight. If Home Assistant expects local time alignment, this could cause the first hour (12am–1am local) to be skipped if the API data is in UTC and not converted. You may need to check how Home Assistant interprets the "start" field and whether it converts it to local time before plotting.