To have gaps in the plot you need to add a data point and set it to null or undefined, which happens automatically when entities go unavailable. If they don’t, the plot leaves no gaps and joins the lines.
You could use the fn filter and inject the null datapoint in between existing datapoints that are too far apart in the time axis.
You can probably get chat gpt to make it if you give it the docs
I’m trying to show the total of each bar in a stacked graph.
I tried to copy this (super clever) solution:
Unfortunately, as you can see from the image below, in my case it seems that it doesn’t work (I can only display the exact value from map_y, not the sum of the other bars), and I can’t figure out why… The only difference I can see between my chart and the ones in the post above is that I’m using statistics: state (because I’m plotting electricity total_increasing sensors in my case).
If you could be so kind as to give me a suggestion, I’d be really grateful!
type: custom:plotly-graph
hours_to_show: 7d
autorange_after_scroll: true
layout:
barcornerradius: 2
barmode: stack
height: 500
margin:
l: 30
r: 10
paper_bgcolor: transparent
plot_bgcolor: transparent
xaxis:
rangeselector:
"y": 1.04
x: 0.03
bgcolor: rgba(130,130,130,0.4)
buttons:
- count: 1
step: day
- count: 7
step: day
- count: 1
step: month
- count: 6
step: month
- count: 1
step: year
yaxis:
fixedrange: true
rangemode: tozero
legend:
orientation: h
x: -0.02
"y": -0.1
yanchor: top
xanchor: left
indentation: -10
hovermode: x unified
defaults:
entity:
unit_of_measurement: ""
period:
0s: 5minute
24h: hour
2d: day
2M: month
texttemplate: "%{y:.2f}"
textposition: inside
hovertemplate: "%{fullData.name}: %{y:.2f} kwh<extra></extra>"
config:
scrollZoom: false
modeBarButtonsToRemove:
- select2d
- lasso2d
- autoScale2d
- resetScale2d
entities:
- entity: sensor.teatrino_1_blu_altre_fonti_energia_consumata_kwh
name: altre fonti
type: bar
statistic: state
filters:
- delta
- filter: i>0
- force_numeric
- store_var: a
marker:
color: rgba(96,96,96,0.5)
line:
width: 0.2
color: rgba(96,96,96,1)
- entity: >-
sensor.shelly_1pm_teatrino_1_blu_bagno_scaldasalviette_energia_consumata_kwh
name: scaldasalviette
type: bar
statistic: state
filters:
- delta
- filter: i>0
- force_numeric
- store_var: b
marker:
color: rgba(255,138,183,0.5)
line:
width: 0.4
color: rgba(255,138,183,1)
- entity: sensor.teatrino_1_blu_luci_energia_consumata_kwh
name: luci
type: bar
statistic: state
filters:
- delta
- filter: i>0
- force_numeric
- store_var: c
marker:
color: rgba(244,189,74,0.5)
line:
width: 0.2
color: rgba(244,189,74,1)
- entity: >-
sensor.shelly_1pm_teatrino_1_blu_lavanderia_lavatrice_energia_consumata_kwh
name: lavatrice
type: bar
statistic: state
filters:
- delta
- filter: i>0
- force_numeric
- store_var: d
marker:
color: rgba(1,171,99,0.5)
line:
width: 0.4
color: rgba(1,171,99,1)
- entity: >-
sensor.shelly_em_gen_3_teatrino_1_blu_piastra_induzione_energia_consumata_kwh
name: induzione
type: bar
statistic: state
filters:
- delta
- filter: i>0
- force_numeric
- store_var: e
marker:
color: rgba(156,107,78,0.5)
line:
width: 0.2
color: rgba(156,107,78,1)
- entity: sensor.shelly_em_gen_3_teatrino_1_blu_forno_energia_consumata_kwh
name: forno
type: bar
statistic: state
filters:
- delta
- filter: i>0
- force_numeric
- store_var: f
marker:
color: rgba(164,99,242,0.5)
line:
width: 0.2
color: rgba(164,99,242,1)
- entity: sensor.shelly_pro_em_teatrino_1_blu_fan_coil_energia_consumata_kwh
name: fan coil
type: bar
statistic: state
filters:
- delta
- filter: i>0
- force_numeric
- store_var: g
marker:
color: rgba(255,114,92,0.5)
line:
width: 0.4
color: rgba(255,114,92,1)
- entity: sensor.shelly_1pm_teatrino_1_blu_lavanderia_boiler_energia_consumata_kwh
name: boiler
type: bar
statistic: state
filters:
- delta
- filter: i>0
- force_numeric
- store_var: h
marker:
color: rgba(66,105,208,0.5)
line:
width: 0.4
color: rgba(66,105,208,1)
- entity: ""
type: bar
name: totale
text: $ex vars.a.ys.map((y,i) =>(y+vars.b.ys[i]+vars.c.ys[i]+vars.d.ys[i]+vars.e.ys[i]+vars.f.ys[i]+vars.g.ys[i]+vars.h.ys[i]).toFixed(0))
showlegend: false
marker:
color: transparent
filters:
- load_var: a
- map_y: 1
I’ve also tried the following variant (without success):
- entity: ""
type: bar
name: totale
text: $ex vars.a.ys.map((y,i) =>(y+vars.b.ys[i]+vars.c.ys[i]+vars.d.ys[i]+vars.e.ys[i]+vars.f.ys[i]+vars.g.ys[i]+vars.h.ys[i]).toFixed(0))
showlegend: false
marker:
color: transparent
filters:
- load_var: a
- load_var: b
- load_var: c
- load_var: d
- load_var: e
- load_var: f
- load_var: g
- load_var: h
- map_y: 1
I’ve also tried the following two chatgpt variants (without success):
Is there any easy way to make sensor data filtering dependent on the active time range? I am aware of the possibility to set period: auto, but I want my raw sensor data in 5s resolution when I zoom in. I was trying to implement it using filters: - resample. Can we pass a string to this depending on the active time range? Thank you!
Thanks David for your quick reply. I saw this solution earlier, thank you! Now I want to pass a string to filters: - resample based on this visible range. I don’t really know javascript and I am relatively new to HA. Do you have any suggestions how I can do it?
A door, by nature, is mostly closed and rarely open. So any graph would be mostly off and only opens for a fraction of the time on the chart. Therefore not being visually aesthetic.
Do any of the designers or bight minds here have a grand idea on how to solve that issue?
Simply making the lines thicker is one easy way, but that does not really look better.
Also it would be cool to display the Timestamp beneath when it opened, and also the duration for how long.
So like a chart with time on X axis and on Y axis display not a value but an icon/textbox with Time and Duration? Would that be possible?
Im trying to get a heating curve in the plotly card. Now first a basic question, but I’m not getting it.
How to get rid off the red crossed things on the picture? Thanks very much in advance.