ApexCharts card - A highly customizable graph card

Thanks, i think this looks better.

hmmmm, and what outcome do you expect ? … a graph of sum: of all days, sorted in month , and span 12 month ?

For now i have daily data, so for now every day a bar is fine. Maybe there are some things showings months, but if i have a graph, i will fix it.

??? montly production, duration month, end month grap_span 12 month,
Solar Monthly Production … yeah, some thing showing months, for sure

I have tried many things, this is the default code for me.

Snyggt!
Would you mind sharing that one?

Hey everyone,

I’m trying to have a chart combined with area filled with a gradient and line.

Unfortunately only same entites are shown with gradients. Others don’t. See below: The third chart (PV-Power) isn’t shown as a gradient, the green one is.

Does anyone know a solution? Would be very happy :slight_smile:

Here is my config:

type: custom:apexcharts-card
graph_span: 24hours
header:
  show: false
  title: xyz
  show_states: false
  colorize_states: true
series:
  - entity: sensor.verbrauch
    name: Eigenverbrauch
    color: green
    float_precision: 0
    yaxis_id: eigenverbrauch
    type: area
  - entity: sensor.myenergi_mein_zuhause_power_import
    color: DodgerBlue
    float_precision: 0
    name: Netzbezug
    type: area
  - entity: sensor.myenergi_mein_zuhause_power_export
    name: Einspeisung
    yaxis_id: einspeisung
    color: Purple
    float_precision: 0
    type: area
  - entity: sensor.pv_power_total
    name: PV
    yaxis_id: pv
    color: Orange
    type: area
  - entity: sensor.battery_charge_power
    name: Aufladen
    color: Pink
    yaxis_id: aufladen
    float_precision: 0
    type: area
  - entity: sensor.battery_discharge_power
    name: Entladen
    color: Turquoise
    yaxis_id: entladen
    float_precision: 0
    type: area
    opacity: 0.3
  - entity: sensor.gosungrow
    name: SOC
    color: black
    float_precision: 0
    yaxis_id: SOC
    type: line
    opacity: 1
all_series_config:
  show:
    extremas: false
  group_by:
    func: avg
    duration: 4m
apex_config:
  chart:
    type: area
    height: 600
  stroke:
    show: true
    lineCap: square
    width: 2
  show:
    extremas: true
  legend:
    show: true
  dataLabels:
    enabled: true
  yaxis:
    - id: eigenverbrauch
      show: true
      showAlways: true
      showForNullSeries: true
      reversed: false
      tickAmount: 7
      decimalsInFloat: 0
      opposite: false
      min: 0
      max: 7000
    - id: netzbezug
      show: false
      opposite: false
      min: 0
      max: 7000
    - id: einspeisung
      show: false
      opposite: false
      min: 0
      max: 7000
    - id: pv
      show: false
      opposite: false
      min: 0
    - id: aufladen
      show: false
      opposite: false
      min: 0
      max: 7000
    - id: entladen
      show: false
      opposite: false
      min: 0
      max: 7000
    - id: SOC
      show: true
      showAlways: true
      showForNullSeries: true
      reversed: false
      tickAmount: 10
      decimalsInFloat: 0
      forceNiceScale: true
      floating: false
      opposite: true
      min: 0
      max: 100
  fill:
    type:
      - gradient
      - solid
    gradient:
      type: vertical
      shadeIntensity: 0.8
      inverseColors: false
      opacityFrom: 0.6
      opacityTo: 0.3
      stops:
        - 0
  tooltip:
    x:
      format: HH:mm

hey guys, im in to apex card and i like it.

  1. As i have it now for example my offpeak tariff is 23:00 - 7:00. Apex card shows offpeak info on 0:00-7:00 when offpeak is over at 7:00 (146kWh) and i want it to show my full offpeak info (172 kWh)

my code looks this way now

- type: vertical-stack
            cards:
              - type: custom:apexcharts-card
                header:
                  show: true
                  title: Day tariff
                graph_span: 14d
                yaxis:
                  - min: 0
                series:
                  - entity: sensor.main_counter_data_daily_peak
                    group_by:
                      func: diff
                      duration: 1d
                    statistics:
                      period: hour
                      type: sum
                      align: start
                    type: column
                    color: '#7b99b5'
                span:
                  start: day
                  offset: '-13d'

you r missing this

Dejavue , haven’t ive seen this post resently ( few days ago) somewhere else ?

Anyway, A day goes from 00.00 to 23.59, so don’t expect that you “just like that” , will see yesterday consumption, in todays
what you see in your “History-line-graph” is what it is ( A line-graph )
SO what you need is to collect/summarize ,00.00>07.00 + 23.00>23.59 ( you have 2 daily peak periods )

Another question is:
Is " Main counter data Daily offpeak" the same as " sensor.main_counter_data_daily_peak " ?

Why do i get a feeling that you show half of what you are trying to accomplice ?

Of course. I followed this article to set up the Nord Pool Spot prices: Home Assistant: Nord Pool Spot prices and how to automate devices for cheapest hours – Creating Smart Home

And now after my latest changes my charts have the following definitions.

Today

type: custom:config-template-card
entities:
  - input_number.max_spotpris
card:
  type: custom:apexcharts-card
  experimental:
    color_threshold: true
  graph_span: 24h
  header:
    title: Nord Pool SE3 today (SEK/kWh)
    show: true
  span:
    start: day
  now:
    show: true
    label: Now
  yaxis:
    - min: 0
      max: 1
  series:
    - entity: sensor.nordpool_kwh_se3_sek_3_10_0
      type: column
      float_precision: 3
      color_threshold:
        - value: 0
          color: var(--success-color)
        - value: ${states['input_number.max_spotpris'].state * 1}
          color: var(--warning-color)
        - value: 2
          color: var(--error-color)
      data_generator: |
        return entity.attributes.raw_today.map((start, index) => {
          return [new Date(start["start"]).getTime(), entity.attributes.raw_today[index]["value"]];
        });

Tomorrow

type: custom:config-template-card
entities:
  - input_number.max_spotpris
card:
  type: custom:apexcharts-card
  experimental:
    color_threshold: true
  graph_span: 1d
  header:
    title: Nord Pool SE3 tomorrow (SEK/kWh)
    show: true
  span:
    start: day
    offset: +1d
  yaxis:
    - min: 0
      max: 1
  series:
    - entity: sensor.nordpool_kwh_se3_sek_3_10_0
      type: column
      float_precision: 3
      color_threshold:
        - value: 0
          color: var(--success-color)
        - value: ${states['input_number.max_spotpris'].state * 1}
          color: var(--warning-color)
        - value: 2
          color: var(--error-color)
      data_generator: |
        return entity.attributes.raw_tomorrow.map((start, index) => {
          return [new Date(start["start"]).getTime(), entity.attributes.raw_tomorrow[index]["value"]];
        });

Max spotpris (input_number.max_spotpris) is a helper:

1 Like

Yeah, it was posted, but got no replies so i did it again with less questions to be solved.
Thank you for your time reading and trying to help.

I have two helpers created from always increasing wifi counter (sensor.kwatttotall_energy)

sensor.main_counter_data_daily_peak. (friendly name Main counter data Daily peak)

sensor.main_counter_data_daily_offpeak (friendly name Main counter data Daily offpeak)

as for the Peak i don’t have such problem, because i get the daily information 7:00-23:00 which is okay (exept a small lag in showing the measurements during the day - i get a little bit less in the chart, but in the sensor is correct info, when the day passes i have the correct info, don’t know why it is happening)

But the main issue is counting that first hour from the passed day.
Your idea is brilliant, but i dont know how to implement it, which method.
Also i was hoping there could be a code inside apex chart framework to fix it

Dream on

No it’s not, i told you , you have 2 peak-hours in a day (in your example !, thou it could have been 3 or 4 ), don’t even think about adding consumption-data from previous day into todays-consumption-data, don’t you see the logic ? … If you drink 5 beer in the morning( lets say between 5-6 am ) and then you drink 3 beer before bedtime ( between 23.00-24.00/00.00 ), You can’t put the last 3 on tomorrows account … or Yesterday evening between 23-00 and 24.00 your solar-power made 1000kWh, and this morning today, between 00- and 07 your solar-power made 200kWh … So today your solar power made 1200kWh … nope

Well i get the point
Maybe i can make another helper which calculates that one only hour every last day
And a template sensor that makes a states summ of yesterdays hour and todays increasing helper (not sure how to describe the past period in template)

It sounds that it could work, but i want to ensure before i spend a few hours working things up and result a fail

1 Like

Seriously, why do you want yesterdays

last hour, in tomorrows consumption ?

Helper: period 1. 00>07 + period 2. 23>23.59 = Todays offpeaK consumption

I heat my house on offpeak using electricity.
on peak i just use regular devices.
so i would like to know how much i pay every night has passed and analyze that if theres more than expected. ( and for me that night calculation begins as the offpeak timechart)
i asked gpt (i know i know) thats what he gave me, but that sh dont work. Maybe he got a good idea with no code knowing?

offpeak_summary:
        value_template: >-
          {% set yesterday = (now() - timedelta(days=1)).strftime('%Y-%m-%d') %}
          {% set prev_day_offpeak = states('sensor.offpeak_' + yesterday + '_23_00') %}
          {{ states('sensor.offpeak') | float + prev_day_offpeak | default(0) | float }}
        unit_of_measurement: "kWh"

ok, so you asked gpt(thx for the nottice :slight_smile: ) … in regards to your suggested template, and your source, i don’t even wanna try it out, i’ll let you have the fun … i don’t even know how to make a “helper” anyway :slight_smile:

PS: i don’t know where you live, thou i do know around here most of i.e yesterday(past days) was OFF-Peak prices heating during daytime was extremely cheap), last night (and tonight) way more expensive, so i don’t even bother making templates, for situations that can’t be predicted …
this and latest night i didn’t run AC-Heating, do to the “price-level” blindly rely “fixed” hours, in a Highly, stupid, crazy , greedy, Commercial society is kind “not optimal”, i have for long time wondered about people eager to find “solutions” for i.e 23:00> 00:07 … sure as “minimum” measure-point it might “help” but in reality, you might find out you could have saved 100buck x 3 last 3 days, by having a “fixed” price-sensor(instead), so you could have skipped i.e the 2 hours between 0500>0700 — or maybe even the “important” hour between 23>24
PS: “todays” off-peak is/was 21-05 tomorrow morning ( or at best 23>04 )

Sure i understand “the concept” … thou i think, i freaking hate cold!, i want i.e 22+ " AS Cheap as possible", so if the price during daytime “when ever” ( at some point is lower than average “past day, coming day”) heat the MF up

Thanks for the help, unfortunatley that wasn’t the solution.
Still only two entites show a gradient, the other stay full.

Anybode else a hint, for a solution?


I wonder if anyone can help.

I’m trying to use your code and it give me this error:

Thank you in advance!