Skip to content

Instantly share code, notes, and snippets.

@nosuchuser
Created April 12, 2024 14:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nosuchuser/5b20e0662c2596f07c94bd170a2b5dac to your computer and use it in GitHub Desktop.
Save nosuchuser/5b20e0662c2596f07c94bd170a2b5dac to your computer and use it in GitHub Desktop.
Home Assistant: Custom ApexChart Card to keep track of Repsol Indexado
# based on https://github.com/luuuis/hass_omie/wiki/ApexChartsYesterdayTodayTomorrow
type: custom:swipe-card
start_card: 2
cards:
- type: custom:apexcharts-card
update_interval: 1h
header:
show: true
title: Yesterday
span:
start: day
offset: '-1d'
graph_span: 1d
all_series_config:
extend_to: false
stroke_width: 2
group_by:
func: avg
duration: 15m
apex_config:
dataLabels:
enabled: true
dropShadow:
enabled: true
series:
- entity: sensor.shelly_em3_quadro_testes_channel_a_power
name: Load
yaxis_id: power
type: area
fill_raw: zero
transform: return x / 1000
unit: kW
show:
legend_value: false
- entity: sensor.template_repsol_spot_price_bihorario
name: Bi-Horário
yaxis_id: price
type: line
curve: stepline
stroke_width: 2
show:
extremas: true
legend_value: false
- entity: sensor.template_repsol_spot_price_simples
name: Simples
yaxis_id: price
type: line
curve: stepline
stroke_width: 0.5
show:
extremas: false
legend_value: false
yaxis:
- id: power
align_to: 0.5
- id: price
opposite: true
align_to: 1
min: '|-10|'
max: '|10|'
- type: custom:apexcharts-card
update_interval: 5m
now:
show: true
header:
show: true
span:
start: day
graph_span: 1d
all_series_config:
type: area
extend_to: false
stroke_width: 2
group_by:
func: avg
duration: 15m
series:
- entity: sensor.shelly_em3_quadro_testes_channel_a_power
name: Consumo
yaxis_id: power
fill_raw: zero
transform: return x / 1000
unit: kW
show:
legend_value: false
- entity: sensor.template_repsol_spot_price_bihorario
name: Bi-Horário
yaxis_id: price
type: line
curve: stepline
data_generator: |
return Object.entries(entity.attributes.today_hours)
.map(([dateString, price]) => [ new Date(dateString), price ])
show:
extremas: true
legend_value: false
- entity: sensor.template_repsol_spot_price_simples
name: Simples
yaxis_id: price
type: line
curve: stepline
stroke_width: 0.5
data_generator: |
return Object.entries(entity.attributes.today_hours)
.map(([dateString, price]) => [ new Date(dateString), price ])
show:
extremas: false
legend_value: false
yaxis:
- id: power
align_to: 0.5
- id: price
opposite: true
min: '|-5|'
max: '|5|'
align_to: 1
- type: custom:apexcharts-card
update_interval: 1h
header:
title: Tomorrow
show: true
span:
start: day
offset: +1d
graph_span: 1d
all_series_config:
type: area
extend_to: false
stroke_width: 2
group_by:
func: avg
duration: 15m
series:
- entity: sensor.template_repsol_spot_price_bihorario
name: Bihorário
yaxis_id: price
type: line
curve: stepline
color: '#E74C3C'
data_generator: >
return ((hs) => Object.keys(hs).map((dt) => [ new Date(dt), hs[dt]
]))(entity.attributes.tomorrow_hours)
show:
extremas: true
legend_value: false
- entity: sensor.template_repsol_spot_price_simples
name: Simples
yaxis_id: price
type: line
curve: stepline
color: '#2B1F1F'
stroke_width: 1
data_generator: >
return ((hs) => Object.keys(hs).map((dt) => [ new Date(dt), hs[dt]
]))(entity.attributes.tomorrow_hours)
show:
extremas: true
legend_value: false
yaxis:
- id: power
align_to: 0.5
- id: price
opposite: true
min: '|-5|'
max: '|5|'
align_to: 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment