First off all, let me reassure you that I have read countless of posts about this subject without finding an answer to my question. I have a template sensor (blue line) which continuously and apparently without reason resets / “jumps”. At first I thought it was just resetting to zero when unavailable, but no. The sensor usually return to previous value, but not always. The issue has a very unfortunate effect on a utility meter with a daily cycle (purple line). All the “negative” values of the utility meter has been manually applied.
… but as you can see in the posted picture the sensor just reset to a value above zero (three times actually), so now I am lost. I am trying the a “availability” aproach, but would really appriciate some help.
Thanks Tom. Is it possible to set it up so not both sensors have to be present? The case is that I can have one sensor (representing one inverter) with production while the other sensor (inverter) does not have production.
If one of them becomes unavailable the value drops. When the missing sensor connects again the value rises. The utility meter will record that rise as actual energy produced.
So both sensors states need to be valid for your template to be available.
Hmm… Let me clarify the situation / case. I have solar panels in different directions and with different inverters (start up voltage and operating range is not the same). It is often the case that one has production and the other does not.
If I am not mistaken, the setup with the availability template would mean that the “total yield” would not be updated “on time”, and maybe not until the next day. I would often have situations where the yield from #1 and #2 would not be equal to the total yield. Is there really no other way in HA to go about this?
I beleive the power sensors from the integration (sensor.inverter_input_power_1) return unavailable and the power sensor I have created (sensor.power_inverter_1_input) will return 0 as it is set to “float(0)”.
To my surprise I see that the integration actually do provide energy sensors for the inverter…
I have been working on a project to create energy sensors for all power flows in an install with battery - and honestly I do not recall that I had the energy sensors or why I have chosen not to use them. I’d like to share the project but not until I am sure it works.
I’ll have to get back to you with regards to if I can use the energy sensors… But would this make it possible to ad two energy sensors without the issue I am getting?
I beleive I have chose not to use the energy sensors provided by Huawei / the Huawei Solar integration, because they do in fact not deliver the true value. Notice the “strange” cut off at 11:15. These sensors take into account that you have a loss in your battery and therfore the does not display the “true” yield nor the actual loss you have using your battery.
I have solved this, and with the sensors I have created I get the true production values and I can monitor the actual loss in the battery + much more.
Below you se my two inverters. It is quite clear how the battery loss is effecting the “calculated yield” on inverter #1. Inverter #1 is my master inverter / the one that the battery is connected to. The “Daily Yield 1 (Energy)” (magenta) is my sensor. The “Inverter Daily yield #1” (dark blue/grey) is the sensor provided by Huawei / the integration.
PS: I’d be happy to share a link to my work, but as mentioned not publicly until I am sure it works without this type of quirks. There is a full README.
The only reason is to have all the power sensors with the same prefix (“power”). Just adds some order and transparency in the work following. This could be omitted.
You can edit the entity_id from the frontend. Click on the entity, in the pop-up window click on the cog icon. You can set the entity id to what you want there.
I am using the sensors from the Huawei Solar integration (sensor.inverter_input_power_1 and _2) directly as input to the energy sensors yield # 1 and #2 which are the sensors added in yield total. I don’t think it can be optimized. Sorry for the wrong description above and not being precise about the usage of the two other power sensors. They are irrelevant in any calculations.
- platform: integration
source: sensor.inverter_input_power_1
name: "Energy Yield #1"
unique_id: energy_yield_1
round: 6
unit_prefix: k
unit_time: h
method: left
- platform: integration
source: sensor.inverter_input_power_2
name: "Energy Yield #2"
unique_id: energy_yield_2
round: 6
unit_prefix: k
unit_time: h
method: left
PS: I’ll edit the first post above, not to confuse others.
Isn’t it a bug that a sensor which has the state_class: total_increasing makes negative jumps? It must be possible to set the sensor only to increase? But then again that might not help if the sensor tries to “jump back”.
All my sensors are simple and so is the one in question. As mentioned in the 3rd post above this the input is directly from the Huawei Solar integration, this input is converted to energy with the platform:integration function in HA and all I am trying to do is to get the sum of two of theses sensors. I hope we can agree that there is no Rube Goldberg about creating a sum of two energy sensors? As said - the rest of my sensors are just as simple. As I have also pointed out the two duplicating power sensor you got caught up in, has no relevance - I don’t use them - I have deleted them yesterday but the issue persists.
I would apricate if you gave this a chance with the above in mind. Thanks.
Your jumps are caused by your template sensor. Tom explained what the cause is and how to fix it. The fix is an availability template on your template sensor that causes the sensor to be unavailable if either one is not available.
This is your only option. Any other option will cause spikes. So you have to ask yourself: Do I want to remove the spikes or do I want to have a 100% persistent uptime sensor. You can’t choose both, you can only choose 1.