Help with percentage history

Hi,

I have a gauge set up to show me the % of my electricity that occured during off-peak times:

    - name: "Imports Octopus Off Peak Percentage"
      unit_of_measurement: '%'
      state: >
        {{ (states('sensor.octo_go_import_offpeak')|float 
         / 
         (states('sensor.octo_go_import_peak')|float + states('sensor.octo_go_import_offpeak')|float)
          * 100) | round(2) | float
        }}

The gauge populates just fine, but the history view is not a line graph like other gauges:

What am I missing please?

Thanks

If you have only just added the unit_of_measurement, the graph will not update until the window of history gets rid of the old non-unit-ed records.

Almost certainly unrelated, but your float filters should have default values: states(...)|float(0) for example, but be careful with using 0 on denominator values.

1 Like

Ah, didn’t know about the window of history. Will check back tomorrow!
Thanks

If you click “show more” from where you took your screenshot, you can constrain the graph to a shorter window, which should confirm that it will display as a line once the old values are shunted left.

Yep, got it! Thanks

1 Like