Closed GiorgioUghini closed 1 year ago
Every midnight, while other statistics resets to zero (in the frontend, in the backend they are still counting energy), the two battery statistics reset to negative values (in the frontend, in the backend they are reset to zero as they are daily stats).
In HA documentation they say that they keep the initial value when the statistic is added, as zero-point... Don't know if this may be relevant?
I think I will first need to read up on the documentation. I don't think the Huawei Fusion Solar API exposes when the data is reset, for probably I will need to recalculate of take the current time or, ...
I don't have much time the coming weeks as I'm busy with other projects. So don't expect a change very soon. Feel free to create a pull request yourself.
Actually, Home Assistant recognize the "last reset" by looking if a "total increasing" sensor goes to zero. At the end the logic is clear: the sensor starts from zero, it is total and it is INCREASING, so it goes to (say) 20kWh, and if this sensor drops to 0, well that's a reset. HA is intelligent enough for this. Problem is that there's something in the initialization phase that set the so-called "zero-value" of the sensor to the value that it has in that moment. In this way, when it resets, it goes back to the zero-value (so if you setup this integration at 4PM when you already produced 15kWh, every middnight, the dashboard will display -15kWh). Calculation is: actual value (0) - zerovalue (15) = -15. I need to evaluate a possible solution for this too. There's no hurry, your work is already excellent as is. Just putting the issue here if anyone would like to contribute. I will, as soon as I manage a possible workaround for this.
Progress so far:
@tijsverkoyen for this specific behavior (battery charge and battery discharge capacities) state_class to totalincreasing will solve the issue. But, we should be able to make this reasoning for all statistics, for example, the daily or monthly_ entities provided by Huawei.
I'm guessing if I'm the only one with this behavior (or maybe I'm the only one with a battery tracked in HA energy dashboard?)
Changing line 535 in sensor.py from FusionSolarRealtimeDeviceDataEnergySensor
to FusionSolarRealtimeDeviceDataEnergyTotalIncreasingSensor
would solve.
But, I'm not sure if doing so would break other things. It shouldn't, but who knows. I'm testing it locally on my HA istance - keep you posted.
I have merged your PR. I will create a PR in a few moments
Hello all, I was seeking some help regarding the energy dashboard configuration upon which I'm struggling a few days now.
Hardware setup
My system include:
Software setup
In the Energy dashboard, I put (json slightly edited for brevity):
{ "stat_energy_from_grid": "sensor.meter_1_reverse_active_energy", "stat_energy_to_grid": "sensor.meter_1_active_energy_forward_active_energy", "stat_energy_from_solar": [ "sensor.inverter_1_mppt_1_dc_total_yield", "sensor.inverter_1_mppt_2_dc_total_yield" ], "stat_energy_from_battery": "sensor.battery_1_discharging_capacity", "stat_energy_to_battery": "sensor.battery_1_charging_capacity" }
Everything works well with this settings, as I do not compute energy twice, a thing that would happen using the inverter power into the
stat_energy_from_solar
field....Issue
In the energy dashboard, I am using several statistics which are total, and the battery statistics that go to zero each day at midnight. When I first added HomeAssistant-FusionSolar integration, HA use the first datapoint value as zero-point, meaning that each midnight I get a drop in the statistics, and during the day, the battery in the energy dashboard is meaningless...
See also:
Similar to: https://github.com/tijsverkoyen/HomeAssistant-FusionSolar/issues/18
Anyone has some advice on how to configure it? Thank you