I am trying to integrate my bluetti AC200L power station into the energy dashboard. The problem I have is I can not select it as a battery system because the sensors are only momentaneous energy flow. What I need is two sensors that display KWh for input and output. Is there a way to generate template sensors that can resemble that?
#Generate Sensor for KWh Tracking
1 messages · Page 1 of 1 (latest)
You should be able to use an integration helper for that https://www.home-assistant.io/integrations/integration
"integration" as in "the mathematical operation of taking the 'rate of change' of something and estimating the total value of it (barring some shift)"
That worked great, thank you! 🙂
Hello. I tried this, but clearly it doesn’t work properly, or I’m missing some information.
I only captured the first 15 seconds while my battery was charging. You can see 500 W, yet the helper has already calculated almost 1 kWh. That’s impossible in just 15 seconds.
Does anyone know what’s going on? Thanks.
Ok I understand. It works if a trigger every 10 seconds. so I have a lot more values
You probably selected trapezoid method, you need to select left instead for the integration sensor.
Left is not the right method of integral for this kind à value because power change often. It's not rectangular.
But instead of updating the sensor source I see max_sub_interval variable that will do the trick
@turbid copper "momentaneous energy flow" isn't a thing, that's called power 🙂
@vocal maple In principle the integration methode depends on how the device reports it's power. But with enough data point they all approach the same value very closely.
But HA does not use fixed (time) buckets but they depend on change. So when set to trapezoidal, if the value is 0W for 5 hours and jumps to 500W, it will take (500W - 0W) / 2 = 250W as average for the whole 5h thus resulting in 1.25kWh. This is rarely what you want. That's why you see the jump in energy the moment the power goes above 0W again. You want the 0W to be counted for the 5h, aka the left value. So left is the best setting in HA for this.
@wide egret looks like you know that function very well. I feed the integration help with another helper which is constantly reporting the same power. Whichmethod do you recommend for that (i have trapezoidal atm and this seems to work fine
@tight glade It still triggers on change, not on an update. So still would use the left methode to not have issues when it has been 0 for a long time.
my template sensors iss constantly reporting 7w. I have set the max part interval to 5 minutes. Is that helping atm ?
This is what happend indeed. I test Left but it seem not super reliable. an other test is trapezoidal but with a max_sub_interval of 10 seconds. I guess both method are fine because it's still a estimation of an integral.
5 minutes is pretty long I would say. But sub interval should also work
At the moment I don't have any anymore. But funny, with left I hear 0 problems and I hear problems with the sub interval not being honored
(I also don't see any reason for left to cause trouble)
And every digital samples signal is an estimation of an integral. Real integral is only possible in the analogue world.
So even with left you don't use max_sub_interval ?
So This for exemple :
- platform: integration source: sensor.puissance_de_decharge_de_la_batterie name: "Énergie déchargée de la batterie - left" unique_id: batterie_energie_decharge_left unit_prefix: k unit_time: h round: 3 method: left
with left most don't use it. As most only have the trouble at 0 as most other values are not stable thus already triggering. But if your value is stable at a value >0 then a max_sub_interval can help. As otherwise the sensor would only update once it changes again. The value will be correct but very much delayed. For example, if the value would be 7w for 5 hours and then change to 20W, it would add 5h x 7W = 35Wh onze it changes. If you set max sub-interval to 30 seconds it will add 0.058Wh every 30 seconds for 5 hours. That would still add up to 35Wh after the 5 hours but if will show it gradual instead of a step after 5 hours.
And 5h at 0W will not result in a step as 5h x 0W = 0Wh 😄
I see thx !
not easy to understand haha
but my yaml above is it correct ? because I do not have any sensors in the helper section and no error. I copy paste from my trapezoidal sensor just replace it by left
I can create it with the UI, but it’s simpler to create all my sensors for my battery in a single file.
I don't see anything wrong here. It is under the sensor key? And you only have a single sensor key? I have to admit, I still hate I can't switch between yaml and UI for this stuff but I do tend to make them in the UI nowadays 😄