tijsverkoyen / HomeAssistant-FusionSolar

Integrate FusionSolar into your Home Assistant.
MIT License
133 stars 25 forks source link

Some numerical sensors do not allow to be used completely in the statistics cards #167

Closed jvcsw closed 2 months ago

jvcsw commented 2 months ago

Describe the bug All numerical sensors do not allow to be used completely in the statistics cards. For exemple, these sensors:

imagen

these sensors have the max, min, mean options disabled

imagen

In this link there is some explanation, but in this sensors the value returns to 0. https://community.home-assistant.io/t/long-term-statistics-max-value-not-available/423889/3?u=jvsystelab

To Reproduce Create a statistics card and select an entity (from the previos list).

Expected behavior The card can be used as a sensor with all the configuration options

Screenshots Above

tijsverkoyen commented 2 months ago

I think the comment in https://community.home-assistant.io/t/long-term-statistics-max-value-not-available/423889/4 is valid here.

These energy sensor are implemented as sensors with the energy device class, which need to have a state class of total or total_increasing.

From the Home Assistant Documentation:

Similar to total, with the restriction that the state represents a monotonically increasing positive total which periodically restarts counting from 0, e.g. a daily amount of consumed gas, weekly water consumption or lifetime energy consumption. Statistics of the accumulated growth of the sensor's value since it was first added is updated every 5 minutes. A decreasing value is interpreted as the start of a new meter cycle or the replacement of the meter.

The sensors are using total_increasing as they reset when the value is lower, which happens at the start of a new periode.

I suspect you want to display the average over a larger period? What you could try is use a helper (template) which uses the state of the energy sensor you want and set the device class to measurement. But this is untested.

jvcsw commented 2 months ago

What I want is to always show the maximum value of daily, monthly, annual production in kW.

tijsverkoyen commented 2 months ago

I don't understand what you are trying to do:

  1. Energy is expressed in kWh, not in kW.
  2. The values are the maximum, as they are only increasing. A lower value means a new period. As in: Total Current Day Energy will only increase during the day. Hence the "Total".
jvcsw commented 2 months ago

Yes, the h was missing.

I have this (daily peak, daily production, max daily production): imagen

To get the third one I had to create a helper (template) of the "measurement" type. And of course, if it works, but I have to do the same for the weekly, monthly, annual and other integration sensors. Everything multiplies.

Is there a solution? Yes But it would be nice if it were not necessary to create the helpers.

tijsverkoyen commented 2 months ago

I don't understand what you expect?

Are you asking me to change the sensors against how Home Assistant has documented? Are you asking to create extra entities with duplicate data?

In my opinion this is a feature request for Home Assistant, to make the average, max, mean, ... available for energy sensors with a state class of total_increasing.

jvcsw commented 2 months ago

Ok.

I don't know if it's possible, I proposed change the sensors to "measurement" type so that they could be used directly in the statistics cards.

Only sensors that reset, for exemple: Total Current Day Energy.

imagen