When using hovermode: x unified is there a way to hide a series from the hoverlabel when the y value is 0? I tried a custom function $fn({}) y >0 y:null but it would just return blank line but the square color of the series was still there.
I’m using auto-entities to pull out all my energy sensors and then the defaults on plotty to setup the functions.
type: custom:auto-entities
card:
type: custom:plotly-graph
hours_to_show: 12
refresh_interval: 60
layout:
hoverlabel:
border: 0
bgcolor: rgba(0, 0, 0, 0.5)
font:
color: white
size: 10
hovermode: x unified
plot_bgcolor: transparent
xaxis:
autorange: true
rangeselector:
"y": 1.2
bgcolor: transparent
activecolor: "#5a5f8e"
font:
color: "#fff"
buttons:
- count: 24
step: hour
- count: 7
step: day
- count: 1
step: month
- count: 3
step: month
- count: 6
step: month
- count: 1
step: year
nticks: 8
showgrid: false
fixedrange: false
yaxis:
autorange: true
nticks: 5
showgrid: false
fixedrange: true
config:
displayModeBar: false
scrollZoom: true
responsive: true
defaults:
entity:
filters:
- force_numeric
- resample: |
$ex {
const range = get('visible_range');
const time_span = range[1] - range[0];
const days = 1000 * 60 * 60 * 24;
if (time_span >= 30 * days) return "1M";
if (time_span >= 3 * days) return "1d";
if (time_span >= 1 * days) return "1h";
return "10m";
}
- derivate: |
$ex {
const range = get('visible_range');
const time_span = range[1] - range[0];
const days = 1000 * 60 * 60 * 24;
if (time_span >= 30 * days) return "M";
if (time_span >= 3 * days) return "d";
if (time_span >= 1 * days) return "h";
return "m";
}
extend_to_present: true
hovertemplate: "%{fullData.name}: %{y:.2f} kWh<extra></extra>"
type: area
fill: tonexty
stackgroup: one
line:
width: 0
shape: spline
statistic: state
period:
0s: 5minute
24h: hour
2d: hour
10d: day
1M: week
3M: week
4M: month
6M: month
1y: month
filter:
template: >
{% set excluded_sensors = state_attr('sensor.excluded_sensors', 'energy') or [] %}
{% set colors = ['#f44336','#e91e63','#926bc7','#6e41ab','#3f51b5','#2196f3','#03a9f4','#00bcd4','#009688','#4caf50','#8bc34a','#cddc39','#ffeb3b','#ffc107','#ff9800','#ff6f22'] %}
{% set ns = namespace(entities=[], index=0) %}
{% set filtered_sensors = states.sensor
| selectattr('attributes.device_class', 'equalto', 'energy')
| selectattr('attributes.unit_of_measurement', 'equalto', 'kWh')
| rejectattr('state', 'equalto', 'unavailable')
| rejectattr('entity_id', 'in', excluded_sensors)
| sort(attribute='attributes.friendly_name', reverse=true)
| list %}
{% set all_sensors = filtered_sensors %}
{% for entity in all_sensors %}
{% set name = state_attr(entity.entity_id, 'friendly_name') | replace('Energy', '') | replace('Power', '') | replace('Summation delivered', '')| trim %}
{% set color = colors[ns.index % colors|length] %}
{% set ns.entities = ns.entities + [{
'entity': entity.entity_id,
'name': name,
'fillcolor': color
}] %}
{% set ns.index = ns.index + 1 %}
{% endfor %}
{% set ns.entities = [{
'entity': 'sensor.grid_energy',
'name': 'Grid Power',
'fillcolor': 'rgba(0, 0, 0, 0.3)',
'type': 'area',
'stackgroup': 'two'
}] + ns.entities %}
{{ ns.entities }}
show_empty: true
unique: true
grid_options:
columns: full
rows: 8
I’ve read up n some of this GitHub discussions which helped with a few items.
my github gist has the code and image plotty-auto-entities-energy-history.yaml · GitHub









