Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"resample" does not allign traces iwth different initial starting points #360

Open
Steph-74 opened this issue Jan 21, 2024 · 1 comment
Open
Labels
bug Something isn't working

Comments

@Steph-74
Copy link

Describe the bug
The "resample" function only resamples the data after the first datapoint of the respective trace was provided by the data base - it does not create entries in the array from the beginning of the reporting periode. If different traces are to be combined, the arrays' length do not match

Screenshots
image

yaml

type: custom:plotly-graph
  - entity: sensor.total_battery_energy_charged
    internal: true
    statistic: sum
    period: 5minute
    filters:
      - delta
      - fn: |
          ({ys}) => {
            let acc = 0;
            return { ys: ys.map(y => acc += y) }
          }
      - store_var: to_battery
  - entity: sensor.total_battery_energy_discharged
    internal: true
    statistic: sum
    period: 5minute
    filters:
      - delta
      - fn: |
          ({ys}) => {
            let acc = 0;
            return { ys: ys.map(y => acc += y) }
          }
      - store_var: from_battery
  - entity: sensor.smart_meter_ts_65a_3_energy_real_produced
    internal: true
    statistic: sum
    period: 5minute
    filters:
      - delta
      - fn: |
          ({ys}) => {
            let acc = 0;
            return { ys: ys.map(y => acc += y) }
          }
      - store_var: to_grid
  - entity: sensor.smart_meter_ts_65a_3_energy_real_consumed
    internal: true
    statistic: sum
    period: 5minute
    filters:
      - delta
      - fn: |
          ({ys}) => {
            let acc = 0;
            return { ys: ys.map(y => acc += y) }
          }
      - store_var: from_grid
  - entity: sensor.wattpilot_totally_charged
    internal: true
    statistic: sum
    period: 5minute
    filters:
      - delta
      - fn: |
          ({ys}) => {
            let acc = 0;
            return { ys: ys.map(y => acc += y) }
          }
      - store_var: to_car
  - entity: sensor.total_photovoltaics_energy
    internal: true
    name: heute
    statistic: sum
    period: 5minute
    filters:
      - delta
      - fn: |
          ({ys}) => {
            let acc = 0;
            return { ys: ys.map(y => acc += y) }
          }
      - store_var: pv_prod
  - entity: ''
    name: heute
    statistic: sum
    period: 5minute
    filters: 
      - load_var: pv_prod
      - map_y: >-
          parseFloat(vars.pv_prod.ys[i]) - parseFloat(vars.to_grid.ys[i]) -
          parseFloat(vars.to_battery.ys[i]) +
          parseFloat(vars.from_battery.ys[i]) + parseFloat(vars.from_grid.ys[i])
      - multiply: 0.001
    line: 
      color: rgba(255, 0, 0, 1)
      width: 2
      shape: spline
    show_value: true

Additional context
See also this discussion

@Steph-74 Steph-74 added the bug Something isn't working label Jan 21, 2024
@dbuezas
Copy link
Owner

dbuezas commented Jan 22, 2024

This will be a bit tricky to fix, I'll need to add a way to keep track of the requested ranges (analogous to visible_range).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants