apexcharts-card icon indicating copy to clipboard operation
apexcharts-card copied to clipboard

Is start_with_last broken?

Open swiergot opened this issue 2 years ago • 19 comments

This is not working as expected:

   -  entity: sensor.daily_yield
      offset: -7d
      statistics:
        type: state
        period: hour
        align: start
      group_by:
        func: diff
        start_with_last: true

It just shows zeros throughout the entire graphspan.

I have debugged the code and the reason is the third IF statement here:

      if (this._config.group_by.start_with_last) {
        if (index > 0) {
          if (bucket.data.length === 0 || bucket.data[0][0] !== bucket.timestamp) {
            const prevBucketData = buckets[index - 1].data;
            bucket.data.unshift([bucket.timestamp, prevBucketData[prevBucketData.length - 1][1]]);
          }

Basically, when retrieving hourly long term statistics, there is only one datapoint in each bucket and the datapoint's timestamp is always equal to the bucket's timestamp.

So the question is: why are the timestamps expected to be different?

swiergot avatar May 18 '22 08:05 swiergot