Template sensor with integration sensor: unavailable when value is zero

Hi,

I have a template sensor:

  # ---------------------------------------------------
  - name: "Elektriciteit subtotaal 2 power"
    unique_id: "sensor.elektriciteit_subtotaal_2_power"
    icon: mdi:flash
    unit_of_measurement: "W"
    state_class: measurement
    state: >
      {{ states('sensor.elektriciteit_kring_a_power') | float(default=0.0) +
         states('sensor.elektriciteit_kring_b_power') | float(default=0.0) +
         states('sensor.elektriciteit_kring_c_power') | float(default=0.0) +
         states('sensor.elektriciteit_kring_d_power') | float(default=0.0) +
         states('sensor.elektriciteit_kring_e_power') | float(default=0.0) 
      }}

and another “integration sensor” that calculates the riemann sum of this sensor

  # ---------------------------------------------------
  - name: "Elektriciteit subtotaal 2 energy"
    unique_id: "sensor.elektriciteit_subtotaal_2_energy"
    platform: integration
    source: sensor.elektriciteit_subtotaal_2_power
    unit_time: h

However, I noticed that if my sensor.elektriciteit_subtotaal_2_power has a static
value of “0.0”, the integration-sensor sensor.elektriciteit_subtotaal_2_energy gets the state of “unavailable”…

also, the graph is not updated anymore (1):

Question:

  • why becomes the integration sensor “unavailable”? when there the parent sensor has a constant value of “0.0” ?
  • why does the graph not update anymore. I would expect a horizontal line as there is no power consumption thus the subtotal of energy consumption should remain constant

kind regards,
Bart

PS
For some very specific reason, I had to redefine the source sensors as follows.
In fact, this is what I mean with a sensor with a permanent value of “0.0”

  # ---------------------------------------------------
  - name: "Elektriciteit Kring A power"
    unique_id: "sensor.elektriciteit_kring_a_power"
    icon: mdi:flash
    unit_of_measurement: "W"
    state_class: measurement
    state: >
        {{ "0" | float(default=0.0) }}
1 Like

I have no idea about the math behind the Riemann integral, but this could b q case of division by 0, which normally would cause an error and knowing HA that would mean no update of the value.
I think it might be a bug.

This is just a sum over time. So normally there would no division by 0

I’m afraid also…

I am experiencing a similar issue. I am integrating the total solar generation power of the day, so the integrated value is unavailable after sunset. Is there any solution?