springfall2008 / batpred

Home battery prediction and charging automation for Home Assistant, supporting many inverter types
https://springfall2008.github.io/batpred/
128 stars 45 forks source link

Add option to chart % rather than just kWh #99

Closed springfall2008 closed 3 months ago

springfall2008 commented 1 year ago

Some users would like charts in battery % rather than kWh

gcoan commented 1 year ago

I have (up to starting with batpred) thought of everything in % terms, which with different sized batteries is awkward. And in terms of kW-to-empty I much prefer using the batpred _soc_kw_h0 current battery soc in kwh (although the entity name is a bit obscure)

mpartington commented 10 months ago

Just wondering if there is an easy way for me to implement this locally outside of predbat. Realise it's it's a nice to have and wouldn't be used by all, so may make the core code too complex. I did take a look at template sensors, but no idea how I would convert all the attribute readings

springfall2008 commented 10 months ago

Sure in the chart code just divide by the battery size and multiply by 100

mpartington commented 10 months ago

Thanks, hadn't thought of that! Got this far now, is there a way to change kWh into % in the chart code, and also change resolution to 0dp?

image
mpartington commented 10 months ago

Well after a lot of googling and trial + error, I managed it! Apex charts is still a black art to me This is the code if useful to anyone else. Instances of 8.36 would need to be replaced with your own usable capacity, and the GivTCP SoC entity updated with inverter serial number.

EDITED to use native predbat % entities where available

`type: custom:apexcharts-card header: show: true title: Home Battery Prediction % show_states: true colorize_states: true graph_span: 60h span: start: minute offset: '-12h' now: show: true yaxis:

image
springfall2008 commented 3 months ago

Closing, as Matt says can be done in the Apex chart