You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi,
I have two statistic sensors that I want to sum up, but that are only defined on partly different time ranges.
I.e. energy consumption of old heater + energy consumption of new heater (different entity) to get a graph of energy consumption of the whole house (in reality it's a bit more complex, but the simplified idea illustrates my problem).
To do so, I tried to fetch two statistics, resample them to 1d and sum them up.
However, the two graphs don't line up after resampling, because they are only defined for different timeframes in the source data.
old: Tue Nov 21 2023 01:00:00 GMT+0100 (Mitteleuropäische Normalzeit) => Fri Jan 10 2025 01:00:00 GMT+0100 (Mitteleuropäische Normalzeit)
new: Wed May 29 2024 02:00:00 GMT+0200 (Mitteleuropäische Sommerzeit) => Fri Jan 10 2025 01:00:00 GMT+0100 (Mitteleuropäische Normalzeit)
So effectively, I can't easily sum those graphs together, since the resampling doesn't extend the data to the actual starting-timestamp of the graph.
Doing something like xs.unshift("2000-01-01T00:00:00"); ys.unshift(0) followed by a resample on both graphs will somewhat improve the situation since now both graphs will start at the same time. However, since I don't know the true starting-timestamp that the user zoomed to, I just picked something very long ago (year 2000). This of course creates thousands of 0-datapoints for each day since 2000.
Is there a simple solution to this? Or do I need to convert vars.gas.xs/vars.gas.ys to a map and do the summation element-by-element with a timestamp lookup?
If not, I would suggest, that "resample" should maybe get an option to extend the bounds to the actual graph-bounds that the user zoomed to. Maybe additionally a fixed value that should be assumed for out-of-bounds data.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi,
I have two statistic sensors that I want to sum up, but that are only defined on partly different time ranges.
I.e. energy consumption of old heater + energy consumption of new heater (different entity) to get a graph of energy consumption of the whole house (in reality it's a bit more complex, but the simplified idea illustrates my problem).
To do so, I tried to fetch two statistics, resample them to 1d and sum them up.
However, the two graphs don't line up after resampling, because they are only defined for different timeframes in the source data.
Example:
Resulting in the log:
So effectively, I can't easily sum those graphs together, since the resampling doesn't extend the data to the actual starting-timestamp of the graph.
Doing something like
xs.unshift("2000-01-01T00:00:00"); ys.unshift(0)
followed by a resample on both graphs will somewhat improve the situation since now both graphs will start at the same time. However, since I don't know the true starting-timestamp that the user zoomed to, I just picked something very long ago (year 2000). This of course creates thousands of 0-datapoints for each day since 2000.Is there a simple solution to this? Or do I need to convert vars.gas.xs/vars.gas.ys to a map and do the summation element-by-element with a timestamp lookup?
If not, I would suggest, that "resample" should maybe get an option to extend the bounds to the actual graph-bounds that the user zoomed to. Maybe additionally a fixed value that should be assumed for out-of-bounds data.
Beta Was this translation helpful? Give feedback.
All reactions