ApexCharts card - A highly customizable graph card

            header:
              show: true
              show_states: false
            series:
              - entity: sensor.netatmo_devonport_tas_indoor_rain_rain_last_hour
                name: Rain Now
                color: deepskyblue
                type: column
                show:
                  name_in_header: true
                  in_header: false
                  datalabels: true
                  in_chart: true
                  legend_value: false
                  extremas: false
              - entity: sensor.netatmo_devonport_tas_indoor_rain_rain_last_hour
                name: Rain Last 24 Hours
                color: deepskyblue
                type: column
                show:
                  name_in_header: true
                  datalabels: false
                  in_chart: false
                  legend_value: false
         - type: custom:apexcharts-card
            graph_span: 24h
            span:
              end: hour
            header:
              show: true
              show_states: true
            apex_config:
              fill:
                type: gradient
                gradient:
                  type: vertical
                  shadeIntensity: 0
                  opacityFrom: 1
                  opacityTo: 0.5
                  stops: 10
              chart:
                height: 150px
              grid:
                show: false
                borderColor: darkslateblue
                strokeDashArray: 2
              dataLabels:
                background:
                  borderWidth: 0
                  opacity: 0
                  foreColor: white
                offsetY: -10
              plotOptions:
                bar:
                  borderRadius: 0
                  dataLabels:
                    position: top
            series:
              - entity: sensor.netatmo_devonport_tas_indoor_rain_rain_last_hour
                name: Rain Now
                color: deepskyblue
                type: column
                group_by:
                  func: raw
                  duration: 1d
                  fill: zero
                statistics:
                  type: state
                  period: hour
                  align: end
                show:
                  name_in_header: true
                  datalabels: true
                  in_chart: true
                  legend_value: false
                  extremas: false
              - entity: sensor.netatmo_devonport_tas_indoor_rain_rain_last_hour
                name: Rain Last 24 Hours
                color: deepskyblue
                type: column
                group_by:
                  func: sum
                  duration: 24h
                  fill: zero
                statistics:
                  type: state
                  period: hour
                  align: end
                show:
                  name_in_header: true
                  datalabels: false
                  in_chart: false
                  legend_value: false
1 Like

Thank you this is what I needed.

@vingerha I did search in doco - but (perhapsim blind) but coudnt find that.

I was a bit confused myself to begin with, different show variables for the chart and then the series. I am pleased you got it going.

1 Like

Hello
Is it possible to create on-the-fly sum from several sensors?

I have sensors providing energy injected and purchased into/from grid in 15-minutes intervals, for each phase. Roughly it looks like on screenshot below.

I would like to add another graph, probably line one (the best if could be on top of that one) summing injected and purchased energy for each phase in those intervals, and then suming all those 3 resuls.
So general formula would be: injA-purchA + (injB-purchB) + (injC-purchC)

The goal is to get final value of energy in 15-min intervals on the graph.

Currently the chart is configured like this:

type: custom:apexcharts-card
graph_span: 24h
update_interval: 10m
all_series_config:
  type: column
  show:
    datalabels: false
    in_chart: true
  float_precision: 2
  group_by:
    duration: 15m
    func: diff
stacked: true
header:
  show: true
  title: Energy 15mins
  show_states: true
  colorize_states: true
series:
  - entity: sensor.wattsonic_phase_a_energy_purchased
    name: Purchased A
    invert: true
    color: "#C1545B"
  - entity: sensor.wattsonic_phase_b_energy_purchased
    name: Purchased B
    invert: true
    color: "#D55C64"
  - entity: sensor.wattsonic_phase_c_energy_purchased
    name: Purchased C
    invert: true
    color: "#EA656D"
  - entity: sensor.wattsonic_phase_a_energy_injected
    name: Injected A
    color: "#4DC1A6"
  - entity: sensor.wattsonic_phase_b_energy_injected
    name: Injected B
    color: "#55D5B8"
  - entity: sensor.wattsonic_phase_c_energy_injected
    name: Injected C
    color: "#5DEAC9"

thanks in advance

is it possible to create a gradient or colour threshold for each bar that tracks the bar instead of horizontal/vertical ?

type: custom:apexcharts-card
chart_type: radialBar
experimental:
  color_threshold: true
  brush: true
header:
  show: false
  title: ApexCharts-Card
  show_states: true
  colorize_states: false
apex_config:
  chart:
    offsetY: 0
    offsetX: 0
    height: 460
  legend:
    show: true
    position: left
    horizontalAlign: right
    floating: true
    offsetX: 40
    offsetY: 10
    fontSize: 14px
    labels:
      useSeriesColors: true
    markers:
      size: 0
    itemMargin:
      vertical: 3
  plotOptions:
    radialBar:
      inverseOrder: false
      offsetY: 0
      startAngle: 0
      endAngle: 270
      hollow:
        size: 10%
        background: transparent
      dataLabels:
        name:
          show: true
        value:
          show: true
  stroke:
    lineCap: round
all_series_config:
  color_threshold:
    - value: 5
      color: red
      opacity: 0.7
    - value: 10
      color: deep orange
    - value: 15
      color: pink
    - value: 20
      color: purple
    - value: 25
      color: deep purple
    - value: 30
      color: indigo
    - value: 40
      color: blue
    - value: 50
      color: lightblue
    - value: 60
      color: cyan
    - value: 70
      color: teal
    - value: 80
      color: green
    - value: 90
      color: lightgreen
series:
  - entity: sensor.badkamer_battery
    name: badkamer
  - entity: sensor.keuken_screen_battery
    name: keuken
  - entity: sensor.rollerblind_0007_battery
    name: lise
  - entity: sensor.sara_voorkant_battery
    name: sara voorkant
  - entity: sensor.sara_zijkant_battery
    name: sara zijkant
  - entity: sensor.rollerblind_0006_battery
    name: w&s
  - entity: sensor.ikea_fyrtur_battery
    name: fyrtur

so more like this:

but then follow the bars individually and match the legend in colour.

1 Like

I just figured out how to do this. Put it inside a horizontal entity stack card which is set to full width. My YAML is:

type: horizontal-stack
cards:
  - type: custom:apexcharts-card
    header:
      show: true
      title: System Temperatures
      show_states: true
      colorize_states: true
    apex_config:
      width: 100%
    series:
      - entity: sensor.wall2_line1_temphumid_line_1_interior_temperature_f_calibrated
        name: Line 1
      - entity: sensor.wall2_line5_temphumid_line_5_interior_temperature_f_calibrated
        name: Line 5
      - entity: sensor.ambientdht22_1_bme280_temperature
        name: Ambient
      - entity: sensor.nutrienttemperaturemonitor_nutrient_temperature_f
        name: Nutrient
    graph_span: 2h
    now:
      show: true
      label: Now
grid_options:
  columns: full
2 Likes

:tada: Check Out My ApexCharts Setup for Temperature and Humidity! :tada:

I’m excited to share my customized ApexCharts graphs that bring my Home Assistant dashboard to life. Here’s what makes them awesome:

:thermometer: Temperature Chart:

  • Displays inside and outside temperatures.
  • Includes the heating setting of the radiator (green line) for better insights into your climate control.

:droplet: Humidity Chart:

  • Shows both inside and outside humidity.
  • Highlights the absolute water content difference between indoor and outdoor air for a deeper understanding of air quality.

:sun_with_face: Additional Features on Both Charts:

  • Tracks sun position (yellow) to show daylight hours.
  • Marks nighttime (purple) for clear visual cues.
  • Logs open window time (grey) for added context on ventilation habits.

ISSUE
I have an issue with the Columns. Only the Stroke is rendered but not the filling.
When I remove the color_threshold of the first series then the columns are rendered full.

image

:chart_with_upwards_trend: Future Plans:
I’d love to add a 4-hour preview to estimate future trends based on historical data from the same time on the previous day. Does anyone know how to achieve this? I’d greatly appreciate any tips or direction on where to start!

Let me know what you think, and feel free to share your ideas for improvements! :rocket:

TEMPERATURE CARD

type: custom:apexcharts-card
header:
  show: true
  show_states: true
  colorize_states: true
  title: Temperatur
update_interval: 15min
cache: true
graph_span: 12h
span:
  offset: "-3h"
now:
  show: true
  label: Jetzt
  color: black
apex_config:
  legend:
    show: false
  yaxis:
    - id: first
      title:
        text: Temperature in °C
      tickAmount: 5
      axisTicks:
        show: true
  grid:
    yaxis:
      lines:
        show: false
    row:
      colors:
        - lightgrey
        - transparent
      opacity: 0.05
yaxis:
  - id: first
    min: ~0
    max: ~30
    decimals: 0
  - id: second
    show: false
    min: ~0
    max: ~60
    decimals: 0
    opposite: true
experimental:
  disable_config_validation: true
  color_threshold: true
all_series_config:
  stroke_width: 4
  group_by:
    duration: 20min
    func: avg
  show:
    header_color_threshold: true
    name_in_header: false
    datalabels: false
    legend_value: true
    extremas: true
series:
  - entity: sensor.aktuelle_temperatur_arbeitszimmer_mittelwert
    yaxis_id: first
    name: Innen
    color_threshold:
      - value: -10
        color: blue
        opacity: 1
      - value: 0
        color: "#99CCFF"
      - value: 10
        color: "#5CADFF"
      - value: 15
        color: "#1F8FFF"
      - value: 20
        color: "#f39c12"
      - value: 21
        color: "#d35400"
      - value: 22
        color: "#c0392b"
      - value: 25
        color: "#F55A5A"
    show:
      name_in_header: true
      in_header: true
      legend_value: true
      extremas: true
  - entity: sensor.hk_arbeitszimmer_nachste_geplante_temperatur
    yaxis_id: first
    type: line
    curve: stepline
    name: Heizung
    color: "#59F564"
    show:
      name_in_header: true
      in_header: true
      datalabels: false
      legend_value: true
      extremas: true
    stroke_width: 2
  - entity: sensor.aussentemperatur_mittlerer_wert
    yaxis_id: first
    type: line
    curve: monotoneCubic
    name: Außen
    color_threshold:
      - value: -10
        color: blue
        opacity: 1
      - value: 0
        color: "#99CCFF"
      - value: 10
        color: "#5CADFF"
      - value: 15
        color: "#1F8FFF"
      - value: 20
        color: "#f39c12"
      - value: 21
        color: "#d35400"
      - value: 22
        color: "#c0392b"
      - value: 25
        color: "#F55A5A"
    show:
      name_in_header: true
      in_header: true
      legend_value: true
      extremas: true
  - entity: binary_sensor.fenster_arbeitszimmer_offnung
    transform: "return x === 'on' ? 60 : 0;"
    yaxis_id: second
    type: area
    curve: stepline
    name: Fenster
    color: white
    show:
      name_in_header: true
      in_header: false
      datalabels: false
      legend_value: true
      extremas: false
    stroke_width: 0
    opacity: 0.25
  - entity: sensor.sun_solar_elevation
    yaxis_id: second
    name: Sonne
    color: yellow
    transform: |
      return Number(x) < 0 ? 0 : Number(x);
    type: area
    opacity: 0.5
    stroke_width: 0
    show:
      name_in_header: false
      in_header: false
      datalabels: false
      legend_value: false
      extremas: false
      in_chart: true
  - entity: sun.sun
    transform: |
      return x === "below_horizon" ? 60 : 0;
    yaxis_id: second
    name: Nighttime
    type: area
    curve: stepline
    color: "#2A2F7F"
    opacity: 0.25
    stroke_width: 0
    show:
      datalabels: false
      in_header: false
      extremas: false
card_mod:
  class: middle-left
grid_options:
  columns: full

HUMIDITY CARD

type: custom:apexcharts-card
header:
  show: true
  show_states: true
  colorize_states: true
  title: Luftfeuchtigkeit
update_interval: 15min
cache: true
graph_span: 12h
span:
  offset: "-3h"
now:
  show: true
  label: Jetzt
  color: black
apex_config:
  legend:
    show: false
  yaxis:
    - id: first
      title:
        text: Luftfeuchtigkeit in %
      tickAmount: 5
      axisTicks:
        show: true
  grid:
    yaxis:
      lines:
        show: false
    row:
      colors:
        - lightgrey
        - transparent
      opacity: 0.05
yaxis:
  - id: first
    min: ~0
    max: ~100
    decimals: 0
  - id: second
    show: false
    min: ~0
    max: ~60
    decimals: 0
    opposite: true
experimental:
  disable_config_validation: true
  color_threshold: true
all_series_config:
  stroke_width: 4
  group_by:
    duration: 20min
    func: avg
  show:
    header_color_threshold: true
    name_in_header: false
    datalabels: false
    legend_value: true
    extremas: true
series:
  - entity: sensor.aktuelle_luftfeuchtigkeit_arbeitszimmer_mittelwert
    yaxis_id: first
    name: Innen
    color_threshold:
      - value: 0
        color: "#98C3E3"
        opacity: 1
      - value: 60
        color: "#4A72CA"
        opacity: 1
      - value: 75
        color: "#FE0002"
        opacity: 1
      - value: 100
        color: "#660001"
        opacity: 1
    show:
      name_in_header: true
      in_header: true
      legend_value: true
      extremas: true
    stroke_width: 6
  - entity: sensor.aktuelle_luftfeuchtigkeit_aussen_mittelwert
    yaxis_id: first
    type: line
    curve: monotoneCubic
    name: Außen
    show:
      name_in_header: true
      in_header: true
      legend_value: true
      extremas: true
    color_threshold:
      - value: -10
        color: blue
        opacity: 1
      - value: 0
        color: "#98C3E3"
      - value: 60
        color: "#4A72CA"
      - value: 75
        color: "#FE0002"
      - value: 100
        color: "#660001"
    stroke_width: 2
  - entity: binary_sensor.fenster_arbeitszimmer_offnung
    transform: "return x === 'on' ? 60 : 0;"
    yaxis_id: second
    type: area
    curve: stepline
    name: Fenster
    color: white
    opacity: 0.25
    show:
      name_in_header: true
      in_header: false
      datalabels: false
      legend_value: true
      extremas: false
    stroke_width: 0
  - entity: sensor.luftfeuchtigkeit_arbeitszimmer_delta_aussen
    yaxis_id: first
    type: column
    group_by:
      duration: 30min
      func: max
    name: Δ g/m³
    color_threshold:
      - value: 0
        color: green
      - value: -3
        color: red
    show:
      name_in_header: true
      in_header: true
      datalabels: false
      legend_value: true
      extremas: true
    stroke_width: 1
    opacity: 0.8
  - entity: sensor.sun_solar_elevation
    yaxis_id: second
    name: Sonne
    color: yellow
    transform: |
      return Number(x) < 0 ? 0 : Number(x);
    type: area
    opacity: 0.5
    stroke_width: 0
    show:
      name_in_header: false
      in_header: false
      datalabels: false
      legend_value: false
      extremas: false
      in_chart: true
  - entity: sun.sun
    transform: |
      return x === "below_horizon" ? 60 : 0;
    yaxis_id: second
    name: Nighttime
    type: area
    curve: stepline
    color: "#2A2F7F"
    opacity: 0.25
    stroke_width: 0
    show:
      datalabels: false
      in_header: false
      extremas: false
card_mod:
  class: middle-right
grid_options:
  columns: full


4 Likes

I created utility meter with 15min resets, to be able to display chart of 15min consumption for the past day. I can nicely group the data and use the last function to get the top value.

With that I get what I want.

type: custom:apexcharts-card
header:
  show: true
  title: 15min consumption for 24h period
  show_states: true
  colorize_states: true
yaxis:
  - id: first_axis
    decimals: 2
    min: 0
    show: true
  - id: second_axis
    decimals: 2
    min: 0
    opposite: true
    show: true
graph_span: 6h
show:
  last_updated: true
series:
  - entity: sensor.utility_meter_15min
    type: column
    group_by:
      func: last
      duration: 15min
    float_precision: 2
    yaxis_id: first_axis

image

Hourly display

To get the hourly, there are somewhat 2 options, either by creating a new utility meter sensor with hourly reset or to sum 4 tops of 15-min sensors. I’m exploring the option nr.2

For that I used the second entry with group by but I used the sum function:

series:
  - entity: sensor.utility_meter_15min
    type: column
    group_by:
      func: last
      duration: 15min
    float_precision: 2
    yaxis_id: first_axis
  - entity: sensor.utility_meter_15min
    type: column
    group_by:
      func: sum
      duration: 1h
    float_precision: 2
    yaxis_id: second_axis

But this does not yield the correct result, because the sum adds all the sensor values within the hour.

image

This is my sensor history:

Sensor updates every minute, so adding value at every minute will produce much higher sum than the reality.

What’s the right way to sum 4 last values that are 15min apart?

1 Like

Or you can do it by setting

Hello guys, I read all the help but I can’t find the solution:
I plot my inverter generated energy values coming from a sensor created from an online json:
-the state is the total generated
-the attributes contain the total generated by week (date,value)

Any way to show the status (total value) for example in the header-title?
I would like to achieve something like:
image
where the N/A shows the total value of the bars already present in the state of the sensor

Thanks

Update:
I’m trying to use this workaround but it seems to me there is a bug:

  • I added a second entity just to grab the “state” value of the sensor containing the total value (as you can see in the screenshot it correctly contains 35.58…)
  • then I hide it from the chart and only enable the view in the header
  • it magically shows a value but wrong… 30.6 that was the value of yesterday, seems to be in the cache and not updated with the other values…

Any ideas?
cache: false is set…

I am a little lost here. I got this temp chart:

Using this code:

      - type: custom:config-template-card
        variables:
          - states['input_select.climate_room'].state
          - states['input_number.target_temp_high'].state
          - states['input_number.target_temp_low'].state
          - states['input_boolean.temp_overlay'].state
          - states['weather.pirateweather'].attributes.temperature
        entities:
          - input_select.climate_room
          - input_number.target_temp_high
          - input_number.target_temp_low
          - input_boolean.temp_overlay
          - weather.pirateweather
        card:
          type: custom:apexcharts-card
          graph_span: 24h
          now:
            show: true
            color: "#87ceeb"
            label: Aktuell
          update_interval: 1m
          yaxis:
            - id: first # identification name of the first y-axis
              decimals: 0
              min: "${vars[3] === 'on' ? parseFloat(vars[4]) - 3 : parseFloat(vars[2]) - 3 }"
              max: "${parseFloat(vars[1]) + 3}"
              apex_config:
                tickAmount: 2
                labels:
                  formatter: |
                    EVAL:function (value) {
                      return Math.round(value) + ' °';
                    }
                  style:
                    fontFamily: Montserrat
          all_series_config:
            stroke_width: 2
          series:
            - entity: sensor.bedroom_temperature
              name: Schlafen
              yaxis_id: first
              opacity: "${vars[0] === 'Schlafen' ? 1.0 : 0.1}"
              fill_raw: last
              group_by:
                func: raw
            - entity: sensor.main_room_temperature
              name: Wohnen
              yaxis_id: first
              opacity: "${vars[0] === 'Wohnen' ? 1.0 : 0.1}"
              fill_raw: last
              group_by:
                func: raw
            - entity: sensor.guest_room_temperature
              name: Gast
              yaxis_id: first
              opacity: "${vars[0] === 'Gast' ? 1.0 : 0.1}"
              fill_raw: last
              group_by:
                func: raw
            - entity: sensor.average_temperature
              name: All
              yaxis_id: first
              opacity: "${vars[0] === 'All' ? 1.0 : 0}"
              fill_raw: last
              group_by:
                func: raw
              show:
                in_legend: false
              curve: smooth
            - entity: weather.pirateweather
              attribute: temperature
              yaxis_id: first
              opacity: "${vars[3] === 'on' ? 1.0 : 0}"
              group_by:
                func: avg
                duration: 1h
              show:
                in_legend: false
          apex_config:
            annotations:
              yaxis:
                - 'y': ${vars[2]}
                  strokeDashArray: 5
                  borderColor: blue
                - 'y': ${vars[1]}
                  strokeDashArray: 5
                  borderColor: red
            legend:
              position: top # Move the legend to the top
              horizontalAlign: center # Center the legend at the top
              fontSize: 12px # Adjust the font size of the legend
              offsetY: 12
              fontFamily: Montserrat
              itemMargin:
                horizontal: 2  # Add horizontal margin to items if needed
            chart:
              height: "250rem"
              padding: 12
            grid:
              show: true
              yaxis:
                lines:
                  show: true # To display horizontal gridlines
              borderColor: var(--color-dark-gray) # Customize the color of the gridlines
              strokeDashArray: 0 # Customize the dash of the gridlines (use 0 for solid lines)
            xaxis:
              labels:
                formatter: |
                  EVAL:function(value) {
                    const date = new Date(value);
                    const hours = date.getHours();
                    const suffix = hours >= 12 ? 'pm' : 'am';
                    const formattedHours = hours % 12 || 12;

                    return hours % 4 === 0 ? formattedHours + suffix : '';
                  }
                style:
                  fontFamily: Montserrat

Question: The “now” badge shows all the way at the end of the graph, naturally. Is there a way that I can have the current states (end of graphs) display somewhere at the 80% marker and then only move the x-axis values along. Meaning that “now” stays where it is and the graphs move to the left, if you know what I mean. That would make reading the temps a lot easier.

Thanks!

I got the same issue that the annotations disappear when the “now” is used

Is forceNiceScale not working anymore? I had good looking scales before but somewhere along the way they are not that “even” (5, 10, 15…) anymore. Looks like the “~” is what is messing with it. If I change 50 to 80 below in the code for the bottom left graph then it looks good again.

yaxis:
  - min: 0
    max: ~50
    apex_config:
      forceNiceScale: true
      decimalsInFloat: 0
      labels:
        style:
          colors: "#ffffff"
          fontSize: 9px
          fontFamily: Arial

Try to Use ‘offset’, there are multiple examples on where and how to apply in the documentation. Or add below so the left side will start at 00:00 and show a whole day

    span:
      start: day
1 Like

I’m trying to create my first ApexChart that I installed via HACS.

I’d like to add captions to the 2 y axes (strings “°C” and “kwh”) but I can’t seem to figure out how to do this.

image

type: custom:apexcharts-card
graph_span: 24h
update_interval: 30s
yaxis:
  - id: temperature
    opposite: false
    min: -10
    max: 40
    show: true
    decimals: 0
  - id: energy
    opposite: true
    min: 0
    show: true
    decimals: 0
all_series_config:
  stroke_width: 1
series:
  - entity: sensor.motion_haustur_temperature
    name: Temperature
    type: line
    yaxis_id: temperature
    color: "#FF0000"
  - entity: sensor.altherma_climatecontrol_heating_daily_electrical_consumption
    name: Heizung
    type: line
    yaxis_id: energy
    color: "#87CEEB"
  - entity: sensor.tibber_accumulated_consumption
    name: Strom gesamt
    type: line
    yaxis_id: energy
    color: "#0000FF"

best regards,

Found the solution:

yaxis:
  - id: temperature
    opposite: false
    min: -10
    max: 30
    show: true
    decimals: 0
    apex_config:
      title:
        text: °C
  - id: energy
    opposite: true
    min: 0
    show: true
    decimals: 0
    apex_config:
      title:
        text: kWh

Hey guys, maybe you can give me some hints.

I still have some things that I like to change.

1.) I managed to get a line for Sunrise, Noon and Sunset
but the offset is in Pixel – percentage does not work
But I like the text to be more at the bottom of the graph closer to the yellow elevation of the sun. So how can I move it and still be able to display the graph in different sizes.

2.) The Area that shows the “Open Window” could have some icons or Text too like the sunrise and Sunset.
its a binary window sensor and I do not know yet how to get the annotations for it.

3.) I like to have some “future” Values for the Temperatur.

  • The Outside Temperature on the bottom from the openweathermap starting from “now” to the end of the graph.
  • the “estimated” inside temperature from the thermostat data from Yesterday.

Here is my current yaml

type: custom:config-template-card
variables:
  mytime: new Date().getTime()
entities:
  - sensor.time
card:
  type: custom:apexcharts-card
  header:
    show: true
    show_states: true
    colorize_states: true
    title: Temperatur
  update_interval: 15min
  cache: true
  graph_span: 12h
  span:
    offset: +3h
    end: minute
  apex_config:
    chart:
      redrawOnWindowResize: true
    forceNiceScale: true
    legend:
      show: false
    annotations:
      position: front
      xaxis:
        - x: ${{ mytime }}
          strokeDashArray: 5
          borderColor: "#F91639"
          opacity: 1
          offsetX: 0
          offsetY: 10
          label:
            borderColor: "#2F0611"
            borderWidth: 0
            text: ${{states['sensor.time'].state}}
            position: top
            orientation: vertical
            textAnchor: middle
            style:
              background: "#F91639"
              color: "#ffffff"
              fontSize: 12px
        - x: ${new Date(states["sensor.pws14_sun_rising"].state).getTime()}
          strokeDashArray: 5
          borderColor: "#FEFBA1"
          label:
            text: ☀️ Sunrise
            orientation: vertical
            borderWidth: 0
            style:
              background: "#0000"
              fontSize: 15px
              rotate: 90
            offsetY: 200
        - x: ${new Date(states['sensor.pws14_sun_solar_noon'].state).getTime()}
          strokeDashArray: 5
          borderColor: "#FFFA34"
          label:
            text: ☀️ noon
            orientation: vertical
            borderWidth: 0
            style:
              background: "#0000"
              fontSize: 15px
            offsetY: 150
        - x: ${new Date(states["sensor.pws14_sun_dusk"].state).getTime()}
          strokeDashArray: 5
          borderColor: "#CD6462"
          label:
            text: 🌙 Sunset
            orientation: vertical
            borderWidth: 0
            style:
              color: "#fff"
              fontSize: 15px
              background: "#0000"
            offsetY: 200
    yaxis:
      - id: first
        title:
          text: Temperature in °C
        tickAmount: 5
        axisTicks:
          show: true
    grid:
      yaxis:
        lines:
          show: false
      row:
        colors:
          - lightgrey
          - transparent
        opacity: 0.05
    dataLabels:
      enabled: false
      zoom:
        enabled: false
      toolbar:
        show: false
        tools:
          download: true
          zoom: true
          zoomin: false
          zoomout: false
          pan: false
          reset: true
    tooltip:
      enabled: false
      theme: light
      style:
        fontsize: 6px
      onDatasetHover:
        highlightDataSeries: true
      x:
        show: true
        format: ddd dd MMM yyyy HH:mm
      marker:
        show: true
      fixed:
        enabled: true
        position: topRight
        offsetX: -10
        offsetY: 0
  yaxis:
    - id: first
      min: ~0
      max: ~30
      decimals: 0
    - id: second
      show: false
      min: ~0
      max: ~60
      decimals: 0
      opposite: true
  experimental:
    disable_config_validation: true
    color_threshold: true
  all_series_config:
    stroke_width: 4
    group_by:
      duration: 20min
      func: avg
    show:
      show:
        extremas: max+time
        in_header: true
        in_chart: false
        datalabels: false
      header_color_threshold: true
      name_in_header: false
      datalabels: false
      legend_value: true
      extremas: true
  series:
    - entity: sensor.aktuelle_temperatur_arbeitszimmer_mittelwert
      yaxis_id: first
      name: Innen
      color_threshold:
        - value: -10
          color: blue
          opacity: 1
        - value: 0
          color: "#99CCFF"
        - value: 10
          color: "#5CADFF"
        - value: 15
          color: "#1F8FFF"
        - value: 20
          color: "#f39c12"
        - value: 21
          color: "#d35400"
        - value: 22
          color: "#c0392b"
        - value: 25
          color: "#F55A5A"
      show:
        name_in_header: true
        in_header: true
        legend_value: true
        extremas: true
      extend_to: now
    - entity: sensor.hk_arbeitszimmer_nachste_geplante_temperatur
      yaxis_id: first
      type: line
      curve: stepline
      name: Heizung
      color: "#59F564"
      show:
        name_in_header: true
        in_header: true
        datalabels: false
        legend_value: true
        extremas: true
      stroke_width: 2
    - entity: sensor.aussentemperatur_mittlerer_wert
      yaxis_id: first
      type: line
      curve: monotoneCubic
      name: Außen
      color_threshold:
        - value: -10
          color: blue
          opacity: 1
        - value: 0
          color: "#99CCFF"
        - value: 10
          color: "#5CADFF"
        - value: 15
          color: "#1F8FFF"
        - value: 20
          color: "#f39c12"
        - value: 21
          color: "#d35400"
        - value: 22
          color: "#c0392b"
        - value: 25
          color: "#F55A5A"
      show:
        name_in_header: true
        in_header: true
        legend_value: true
        extremas: true
      extend_to: now
    - entity: binary_sensor.fenster_arbeitszimmer_offnung
      transform: "return x === 'on' ? 60 : 0;"
      yaxis_id: second
      type: area
      curve: stepline
      name: Fenster
      color: "#73E2E5"
      show:
        name_in_header: true
        in_header: false
        datalabels: false
        legend_value: true
        extremas: false
      stroke_width: 0
      opacity: 0.25
    - entity: sensor.sun_solar_elevation
      yaxis_id: second
      name: Sonne
      color: yellow
      transform: |
        return Number(x) < 0 ? 0 : Number(x);
      type: area
      opacity: 0.5
      stroke_width: 0
      show:
        name_in_header: false
        in_header: false
        datalabels: false
        legend_value: false
        extremas: false
        in_chart: true
      extend_to: false
      group_by:
        duration: 5min
        func: max
    - entity: sun.sun
      transform: |
        return x === "below_horizon" ? 60 : 0;
      yaxis_id: second
      name: Nighttime
      type: area
      curve: stepline
      color: "#2A2F7F"
      opacity: 0.5
      stroke_width: 0
      show:
        datalabels: false
        in_header: false
        extremas: false
  card_mod:
    class: middle-right
grid_options:
  columns: full

1 Like

I have a weird problem with my radial chart … it diesnt seem to be showing the correct percentage on the radial bars.

I have a normal bar graph that shows the actual values of the sensor … it can be seen below

image

Now when you look at the bar graph you can see so far today its been say approx 16 hours out of 24. My school arithmetic states that’s approx 67%. If we look at the radial bar for 1 day you can see its definitely not 67% its saying 17%

image

Below is my code for this particular chart

type: custom:apexcharts-card
update_interval: 1min
view_layout:
  position: sidebar
apex_config:
  legend:
    show: true
    floating: true
    fontSize: 16px
    position: left
    offsetX: 0
    offsetY: 10
    labels:
      useSeriesColors: true
    markers:
      size: 0
    itemMargin:
      vertical: 3
  chart:
    height: 370px
  plotOptions:
    radialBar:
      offsetY: 0
      startAngle: 0
      endAngle: 270
      hollow:
        margin: 5,
        size: 30%
        background: transparent
      dataLabels:
        name:
          show: false
        value:
          show: false
header:
  title: Time in Range
  show: true
  show_states: false
  colorize_states: false
chart_type: radialBar
experimental:
  color_threshold: true
series:
  - entity: sensor.glucose_time_in_range_month
    name: 30d
    color: "#9B59B6"
    float_precision: 0
  - entity: sensor.glucose_time_in_range_fortnight
    name: 14d
    color: "#E74C3C"
    float_precision: 0
  - entity: sensor.glucose_time_in_range_week
    name: 7d
    color: "#3498DB"
    float_precision: 0
  - entity: sensor.glucose_time_in_range_day
    name: 1d
    color: "#FF9800"
    float_precision: 0
card_mod:
  style: |
    ha-card:active {
    transform: scale(0.9);
    transition: 0s;
    }    
    ha-state-icon {
       --icon-symbol-size: 50px;
       padding-bottom: 20px;
       height: 20px;
    }    
    ha-card {
      border-radius: var(--ha-card-border-radius) !important;
      --ha-card-background: rgb(64,64,64,0.7);
      --card-mod-icon-color: white;
      --card-primary-color: white;
      --card-secondary-color: white;
      --primary-text-color: white;
      --font-weight: bold;
      --secondary-text-color: white;
    }  

Does anyone know what i am doing wrong here ? I suspect the the other 3 radials will also havethe same issue but time hasnt passed enough yet for me to check.

Appreciate any assistance given

[UPDATE] I just resolved this by using maths and template sensors to convert the time in hours to a percentage of hours over the period

    glucose_time_in_range_day_percentage:
      unique_id: glucose_time_in_range_day_percentage
      value_template: >
        {% set value= states('sensor.glucose_time_in_range_day') | float %}
        {{ ((value) * 4.167 | round(2, default=0)) }}

    glucose_time_in_range_week_percentage:
      unique_id: glucose_time_in_range_week_percentage
      value_template: >
        {% set value= states('sensor.glucose_time_in_range_week') | float %}	
        {{ ((value) * 0.595238095 | round(2, default=0)) }}  
         
    glucose_time_in_range_fortnight_percentage:
      unique_id: glucose_time_in_range_fortnight_percentage
      value_template: >
        {% set value= states('sensor.glucose_time_in_range_fortnight') | float %}	
        {{ ((value) * 0.297619048 | round(2, default=0)) }}           

    glucose_time_in_range_month_percentage:
      unique_id: glucose_time_in_range_month_percentage
      value_template: >
        {% set value= states('sensor.glucose_time_in_range_month') | float %}	
        {{ ((value) * 0.138888889 | round(2, default=0)) }}     
```

The weather entity changed in Homeassistant 2024.3 - how does it work with the new version?

This has nothing to do with ApexCharts as it does not support working with services/sections. You have to create your own forecast sensor and outside of the thread there are numerous posts on the topic and how to do this.