Comments (5)
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:
- min: 0
max: 100
decimals: 0
series: - entity: sensor.givtcp_SERIAL_soc
stroke_width: 1
curve: stepline
name: actual
extend_to: now
show:
in_header: true - entity: predbat.soc_kw
stroke_width: 1
curve: smooth
name: base
unit: '%'
float_precision: 0
data_generator: >
let res = []; for (const [key, value] of
Object.entries(entity.attributes.results)) { res.push([new
Date(key).getTime(), value*100/8.36]); } return res.sort((a, b) => {
return a[0] - b[0] })
show:
in_header: true - entity: predbat.soc_kw_best
stroke_width: 3
curve: smooth
name: best
unit: '%'
float_precision: 0
data_generator: >
let res = []; for (const [key, value] of
Object.entries(entity.attributes.results)) { res.push([new
Date(key).getTime(), value*100/8.36]); } return res.sort((a, b) => {
return a[0] - b[0] })
show:
in_header: true - entity: predbat.soc_kw_best10
stroke_width: 1
curve: smooth
name: best10
unit: '%'
float_precision: 0
data_generator: >
let res = []; for (const [key, value] of
Object.entries(entity.attributes.results)) { res.push([new
Date(key).getTime(), value*100/8.36]); } return res.sort((a, b) => {
return a[0] - b[0] })
show:
in_header: true - entity: predbat.best_charge_limit
stroke_width: 4
curve: stepline
name: charge_limit_best
unit: '%'
float_precision: 0
type: area
opacity: 0.2
data_generator: >
let res = []; for (const [key, value] of
Object.entries(entity.attributes.results)) { res.push([new
Date(key).getTime(), value]); } return res.sort((a, b) => { return a[0] -
b[0] })
show:
in_header: raw - entity: predbat.charge_limit
stroke_width: 1
curve: stepline
name: charge_limit_base
float_precision: 0
data_generator: >
let res = []; for (const [key, value] of
Object.entries(entity.attributes.results)) { res.push([new
Date(key).getTime(), value]); } return res.sort((a, b) => { return a[0] -
b[0] })
show:
in_header: raw - entity: predbat.best_discharge_limit_kw
stroke_width: 2
curve: stepline
name: discharge_best
unit: '%'
float_precision: 0
data_generator: >
let res = []; for (const [key, value] of
Object.entries(entity.attributes.results)) { res.push([new
Date(key).getTime(), value*100/8.36]); } return res.sort((a, b) => {
return a[0] - b[0] })
show:
in_header: true - entity: predbat.record
stroke_width: 3
curve: stepline
name: record
type: area
opacity: 0.5
color: black
data_generator: >
let res = []; for (const [key, value] of
Object.entries(entity.attributes.results)) { res.push([new
Date(key).getTime(), value*100/8.36]); } return res.sort((a, b) => {
return a[0] - b[0] })
show:
in_header: true - entity: predbat.soc_kw_base10
stroke_width: 1
curve: smooth
name: base10
unit: '%'
float_precision: 0
data_generator: >
let res = []; for (const [key, value] of
Object.entries(entity.attributes.results)) { res.push([new
Date(key).getTime(), value*100/8.36]); } return res.sort((a, b) => {
return a[0] - b[0] })
show:
in_header: true
`
from batpred.
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)
from batpred.
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
from batpred.
Sure in the chart code just divide by the battery size and multiply by 100
from batpred.
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?
from batpred.
Related Issues (20)
- IOG on 7.18.2 - still doesn't charge at 11.30pm HOT 3
- Fatal Errors after last night's update HOT 17
- Fatal error with 7.18.4 HOT 1
- Predbat Status - "ERROR: Exception raised 'PredBat' object has no attribute 'now;" HOT 3
- Hass.get history issue with latest update HOT 6
- PauseCharge was not switched off when a charge window was planned/enabled, so battery would not charge HOT 4
- Charge window not updated to reflect changes in plan HOT 4
- 7.19.0 errors HOT 7
- Unusually high overnight SOC HOT 7
- Query about the accuracy of suggested charge and discharge rate from the 'auto generate charge curve' routines HOT 2
- Predbat Savings sensors innaccurate HOT 1
- Predbat not working after latest update HOT 15
- NoCharge drawing from grid and not reducing current SOC to target
- Turning off set_reserve_enable doesnโt restore set reserve to default
- Exception raised when updating to v7.19.2 HOT 1
- Multi-threading for Region Optimisation HOT 1
- New Pause mode is no longer being set - it errors out HOT 1
- Predbat not working on all updates after v17.19.0 - Exception Raised 1440/1470 HOT 3
- Inverter time not updating HOT 2
- Carbon Intensity no appearing in my plan - Something I've not configured correctly HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from batpred.