Skip to content

Conversation

@dwmw2
Copy link
Contributor

@dwmw2 dwmw2 commented Dec 1, 2025

When there are gaps in the data (e.g., device offline for multiple days), the accumulated usage appears as a large spike on the day data resumes. This preprocessing function detects gaps and spreads the accumulated value evenly across the missing days, preventing spikes from affecting graph scale.

It used to look like this:
Screenshot from 2025-12-01 11-32-14

... now it looks like this:

Screenshot from 2025-12-01 11-53-24

@dwmw2 dwmw2 changed the title Spread data spikes over missing days in counter graphs [WIP] Spread data spikes over missing days in counter graphs Dec 1, 2025
@dwmw2
Copy link
Contributor Author

dwmw2 commented Dec 1, 2025

For some reason this isn't working on my production box even though it was working in testing on the same type of meter device.

@dwmw2
Copy link
Contributor Author

dwmw2 commented Dec 1, 2025

Ah, I figured it out. My test server had gaps where Domoticz itself hadn't been running. My production server had been running but the meter data hadn't been coming in, so there were actual zeroes in the data and not just gaps:

    {
      "d": "2025-03-02",
      "v": "97.703"
    },
    {
      "d": "2025-03-03",
      "v": "87.305"
    },
    {
      "d": "2025-03-04",
      "v": "0.000"
    },
    {
      "d": "2025-03-05",
      "v": "0.000"
    },

I'm confused by the presence of zeroes; surely we shouldn't be writing to Meter_Calendar for that day if the device hasn't actually updated at all?

We can tweak the graph code to treat those like empty data, but I'm less sure that we should. What do you think?

dwmw2 added 2 commits December 1, 2025 18:27
When a device hasn't updated within the timeout period, UpdateMeter()
already prevents entries from being added to the Meter table. The
AddCalendarUpdateMeter() function should leave gaps in Meter_Calendar
rather than explicitly inserting zeros, allowing the graph smoothing
code to handle the missing data appropriately.
When there are gaps in the data (e.g., device offline for multiple days),
the accumulated usage appears as a large spike on the day data resumes.
Detect gaps and spread the accumulated value evenly across the missing
days to prevent spikes from affecting graph scale.

The fillMissingDays function is implemented in the shared
counterLogSeriesSupplier module and used by all counter/meter device
types (energy-used, energy-generated, gas, water, counter, P1 energy).
@dwmw2 dwmw2 changed the title [WIP] Spread data spikes over missing days in counter graphs Spread data spikes over missing days in counter graphs Dec 1, 2025
@dwmw2
Copy link
Contributor Author

dwmw2 commented Dec 1, 2025

Fixed the code which introduced the zeroes. We deliberately don't introduce explicit zeroes in the Meter table, and we shouldn't in Meter_Calendar either. Then the JS code which smooths over empty days will be fine.

@gizmocuz gizmocuz force-pushed the development branch 2 times, most recently from a0a55cd to e57a1b6 Compare December 2, 2025 11:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant