Giter Site home page Giter Site logo

Comments (5)

mpartington avatar mpartington commented on June 9, 2024 2

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
    `
image

from batpred.

gcoan avatar gcoan commented on June 9, 2024

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.

mpartington avatar mpartington commented on June 9, 2024

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.

springfall2008 avatar springfall2008 commented on June 9, 2024

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

from batpred.

mpartington avatar mpartington commented on June 9, 2024

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

from batpred.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.