Question about calculating sensor values of an entity

I get Data from the GeoSphere Austria Integration.
Among other entities, there is an entity that delivers me a value every 10 minutes, with the sunshine duration of the last 10 minutes in seconds.

I want to make a Dashboard which is showing me the how much % of the day the sun was shining.

The only Problem is, if there is no Change, no new measuring is written in the history.
Only if there is a change.
So if I sum all values I get a wrong result.

For example:

On April 7th there nearly was full sun the whole day.
Nevertheless, in my evaluation I only get 2.612 Seconds of Sunshine.

Is there a way to calculate the correct sum of Seconds with the existing entity or do I have to make my own automation which is “feeding” a own sensor all 10 Minutes with the data of the existing entity?

Thank you for your help!

Can you please show the yaml configuration for your “evaluation”?

This is the code from the Card:

type: custom:mini-graph-card
  - entity: sensor.wien_hohe_warte_sun_last_10_minutes
name: Sonnenscheindauer
  - value: 0
    color: '#ffffff'
hours_to_show: 168
icon: mdi:theme-light-dark
aggregate_func: sum
group_by: date
  graph: bar
  labels: true
  points: false
  fill: true
  extrema: true
  average: true
  icon_adaptive_color: true
  legend: true

The result is similar to the result when I manually calculate the data points.

I marked all Datapoints with a red Dot.

The values oft he Datapoints are:

SUM: 2612

I know, of course, that for efficiency reasons it doesn’t make sense to write a new data set every time the same values ​​are used.
I also know that I can calculate the duration of the data’s validity using the time stamp. I’m just not sure how to implement this in HA, other than quick and dirty using automation.

Try this triggered template sensor:


  - trigger:
      - platform: time_pattern
        minutes: "/10" # update every 10 minutes
        seconds: "0"
      - platform: time # reset at just past midnight
        at: "00:00:05"
        id: reset
      - name: "Daily Sunshine Duration"
        unit_of_measurement: s
        state: >
          {% if == 'reset' %}
          {% else %}
            {{ states('sensor.daily_sunshine_duration')|float(0) + 
               states('sensor.wien_hohe_warte_sun_last_10_minutes')|float(0) }}
          {% endif %}

It won’t be exact as the trigger is not synchronised to the GeoSphere sensor update, but it should be pretty close.

1 Like

Thank you so much!

Unfortunately today there is not a single second sunschine.

But I’m sure it’s exact because GeoSphere sensor is updating every 10 Minutes and your Sensor also updates every 10 Minutes so the sum always match.

And the trigger part is very interesting.
I’m sure I can use it in future projects.