phio
(Philip Cheong)
January 26, 2023, 7:15pm
1
Rather that display the last sensor states in the header in this graph, which are: (0.1kWh, 0.5kWh, 0kWh)
I would like to display the sum of the sensor states for the period that are in the graph, which instead would be something like (37.5kWh, 5.9kWh, 0kWh).
Seems like the data_generator might be able to do this?
Here is my current config for the apexchart card:
type: custom:apexcharts-card
header:
show: true
title: Energy usage
show_states: true
colorize_states: true
show:
last_updated: false
stacked: true
graph_span: 24h
span:
start: day
offset: '-1d'
series:
- entity: sensor.total_mill_energy
type: column
group_by:
func: diff
duration: 1h
start_with_last: true
- entity: sensor.total_hot_water_energy
type: column
group_by:
func: diff
duration: 1h
start_with_last: true
- entity: sensor.tesla_charging
type: column
group_by:
func: diff
duration: 1h
start_with_last: true
2 Likes
You could try duplicating the entities (ie. now 6 series), and having the group-by duration for the second set being “1d”. Then for the original 3 set “in_header” to false, and the new 3 set “in_chart” to false. I’ve not tried it, but easy to test at least.
pjvenda
(Pedro venda)
June 28, 2023, 11:04am
3
@phio did you find a solution for this? I’m looking for the same kind of functionality.
I tried @michaelblight suggestion but it seems to be integrating all values taken through the day so the daily sum is something silly.
phio
(Philip Cheong)
June 28, 2023, 8:03pm
4
Yeah, I rebuilt the graphs in grafana
1 Like
levid0s
(levid0s)
January 7, 2024, 2:35am
5
Managed to get this working by duplicating the entities and putting them on a hidden yaxis.
type: custom:apexcharts-card
experimental:
color_threshold: true
header:
show: true
title: Consumption Yesterday v2
show_states: true
colorize_states: true
update_interval: 1h
graph_span: 24h
span:
start: day
offset: '-48h'
yaxis:
- id: cost
min: ~0
decimals: 2
align_to: 0.05
- id: consumption
min: ~0
decimals: 2
opposite: true
align_to: 0.1
- id: hidden
show: false
series:
- entity: >-
sensor.octopus_energy_electricity_xxxx_xxxxxxxx_previous_accumulative_cost
name: Cost
type: line
color: green
yaxis_id: cost
float_precision: 3
opacity: 1
stroke_width: 3
unit: GBP
show:
in_chart: true
in_header: false
legend_value: false
color_threshold:
- value: -100
color: cyan
- value: 0
color: lightgreen
- value: 0.1
color: orange
- value: 0.2
color: red
- value: 0.3
color: purple
data_generator: |
return entity.attributes.charges.map((entry) => {
return [new Date(entry.from), entry.cost_raw];
});
- entity: sensor.octopus_energy_electricity_xxxx_xxxxxxxx_current_rate
name: Unit rate
type: line
color: darkcyan
yaxis_id: cost
stroke_width: 1
show:
in_chart: true
in_header: false
legend_value: false
color_threshold:
- value: -100
color: cyan
- entity: >-
sensor.octopus_energy_electricity_xxxx_xxxxxxxx_previous_accumulative_consumption
name: kWh
type: column
yaxis_id: consumption
stroke_width: 8
show:
in_chart: true
in_header: false
legend_value: false
color: grey
color_threshold:
- value: -100
color: '#777777'
float_precision: 3
data_generator: |
return entity.attributes.charges.map((entry) => {
return [new Date(entry.from), entry.consumption];
});
- entity: >-
sensor.octopus_energy_electricity_xxxx_xxxxxxxx_previous_accumulative_cost
yaxis_id: hidden
unit: GBP
show:
in_header: raw
header_color_threshold: true
in_chart: false
name_in_header: false
float_precision: 2
color_threshold:
- value: -100
color: cyan
- value: 1.5
color: green
- value: 2.3
color: orange
- value: 3
color: red
- value: 4
color: purple
- entity: >-
sensor.octopus_energy_electricity_xxxx_xxxxxxxx_previous_accumulative_consumption
yaxis_id: hidden
color: grey
show:
in_header: raw
name_in_header: false
header_color_threshold: false
in_chart: false
legend_value: false
float_precision: 2
1 Like
ando2040
(Ando2040)
April 26, 2024, 7:40pm
6
Nice graph! Couple of things might have changed in the OctopusDave integration:
entry.from is now entry.start
entry.cost_raw is now entry.cost
Offset: -24h was needed for me.
Hope that helps someone else avoid the debugging I did!
Hi, can anyone help me?
In the graph I can’t show the third column…
The sesor is sum and difference other sensor:
sensors:
deye_daily_load_consumption_completed:
friendly_name: "Daily Load Consumption (Completed)"
unit_of_measurement: 'kWh'
value_template: '{{ states("sensor.deye_daily_production") |float(0) -
states("sensor.deye_daily_battery_charge") | float(0) +
states("sensor.deye_daily_battery_discharge") |float(0) +
states("sensor.deye_daily_energy_bought") |float (0)
}}'
the card:
type: custom:apexcharts-card
apex_config:
chart:
height: 300px
graph_span: 7day
span:
end: day
show:
last_updated: true
header:
show: true
show_states: true
colorize_states: true
title: ANDAMENTO GIORNALIERO
yaxis:
- id: consuption
min: ~0
decimals: 2
align_to: 0.1
max: "|+5|"
series:
- entity: sensor.deye_daily_energy_bought
yaxis_id: consuption
type: column
name: ACQUISTO ENERGIA
color: rgb(84, 144, 194)
show:
datalabels: false
group_by:
func: diff
duration: 1day
statistics:
type: state
period: 5minute
transform: return Number(x) * 1.0;
unit: kWh
- entity: sensor.deye_total_production
yaxis_id: consuption
type: column
name: PRODUZIONE PANNELLI
show:
datalabels: false
color: rgb(255, 155, 48)
group_by:
func: diff
duration: 1day
statistics:
type: state
period: 5minute
transform: return Number(x) * 1.0;
unit: kWh
float_precision: 2
- entity: sensor.deye_daily_load_consumption_completed
name: CONSUMO CASA
yaxis_id: consuption
color: grey
type: area
group_by:
func: max
duration: 1day
statistics:
type: max
period: 5minute
show:
in_header: raw
name_in_header: true
header_color_threshold: false
in_chart: true
legend_value: true
float_precision: 2
Thank you all