Aktuell blitzt und donnert es hier in unserem Teil der Republik. Endlich eine Gelegenheit, eine Conditional Blitz-Karte zu bauen und auch anzuzeigen:
type: conditional
conditions:
- condition: state
entity: binary_sensor.blitzwarnung_aktiv
state: "on"
card:
type: custom:vertical-stack-in-card
cards:
- type: custom:mushroom-template-card
entity: sensor.5e_lightning_strike_distance
icon: >
{% set d = states('sensor.5e_lightning_strike_distance') | float(999) %}
{% if d < 5 %}
mdi:lightning
{% elif d < 15 %}
mdi:weather-lightning
{% elif d < 30 %}
mdi:weather-cloudy
{% else %}
mdi:check-circle-outline
{% endif %}
icon_color: >
{% set d = states('sensor.5e_lightning_strike_distance') | float(999) %}
{% if d < 5 %}
purple
{% elif d < 15 %}
red
{% elif d < 30 %}
amber
{% else %}
green
{% endif %}
fill_container: true
tap_action:
action: more-info
primary: >
{% set t = states('sensor.5e_lightning_last_strike') %} {% set age =
now().timestamp() - as_timestamp(t) %} Blitz vor {{ (age | float(0) / 60
)| round(0) }} min
secondary: >
{% set d = states('sensor.5e_lightning_strike_distance') | float(999)
%}
{% set unit = state_attr('sensor.5e_lightning_strike_distance',
'unit_of_measurement') %}
{% if d < 5 %}
Sehr nah: {{ d | round(1) }} {{unit}}
{% elif d < 15 %}
In der Nähe: {{ d | round(1) }} {{unit}}
{% elif d < 30 %}
Entfernt: {{ d | round(1) }} {{unit}}
{% else %}
Kein Einschlag registriert
{% endif %}
- type: custom:plotly-graph
entities:
- entity: sensor.5e_lightning_strike_distance
name: Entfernung
type: bar
transform: last
line:
color: |
[
(v < 5) ? 'red' :
(v < 10) ? 'orange' :
(v < 15) ? 'yellow' : 'gray'
]
width: null
hours_to_show: 2
refresh_interval: 30
layout:
title: ""
bargap: 0.3
yaxis:
title: Entfernung (km)
rangemode: tozero
showgrid: true
xaxis:
title: Zeit
type: date
showgrid: false
showlegend: false
Benötigt wird auch ein template binary_sensor, um die Karte nur bei aktuellen Ereignissen anzuzeigen - und später die Automatisierung zu triggern.
{% set dist = states('sensor.5e_lightning_strike_distance') | float(999) %}
{% set t = states('sensor.5e_lightning_last_strike') %}
{% set dist_max = 30 %}
{% set age_max = 900 %}
{% if t in ['unknown','unavailable', None] %}
unknown
{% else %}
{% set age = now().timestamp() - as_timestamp(t) %}
{{ dist < dist_max and age < age_max }}
{% endif %}
Mit der Grafik werde ich wohl noch ein wenig Zeit verbringen - Plotly ist noch nicht im Rückenmark
Jetzt denke ich an eine Automatisierung, die mir bei Blitzen in der Nähe eine Warnung auf Telefon, Fernseher, PC, … (Ist schon fast fertig )