There is a very nice integration called meteoalarm available.
It gives some standardized weather alerts for Europe.
The result is very thoruough, but also quite complex to use (IMO).
I had this set up quite a while ago, and then some of the custom plugins I used got deprecated, so I had to reformat the output.
So first of I’ve set up a few template sensors thanks to the help from @123 and others:
First of is the sensor itself, secondly some sensors that will format the string conditionally, so that I can split the event attribute, and use the colour code and event type directly in the output.
binary_sensor:
- platform: meteoalarm
country: 'DK'
language: 'da'
province: 'København og Nordsjælland'
sensor:
- platform: template
sensors:
meteo_type:
value_template: >
{% set v = state_attr('binary_sensor.meteoalarm', 'event') %}
{{ 'off' if v == none else v.split(" ")[1] }}
meteo_colour:
value_template: >
{% set v = state_attr('binary_sensor.meteoalarm', 'event') %}
{{ 'off' if v == none else v.split(" ")[0] }}
Then there is the card, to use these values properly, this is where all ‘the magic’ happens.
The lead texts are in danish. The only problem remaining is why the strftotime doesn’t use the danish locale, and I don’t see a way to have this set, which is really bad, it should be possible to do so, so that you don’t have to build complex sensors just to cludge the translation:
card:
content: >
### <font color={{ states('sensor.meteo_colour') }}>{{
state_attr('binary_sensor.meteoalarm','headline') }} </font><br/><hr>
<b>Alvorlighed</b> <font color={{ states('sensor.meteo_colour') }}> {{
state_attr('binary_sensor.meteoalarm','severity') }}</font><br/>
<b>Type</b> <font color= #4caf50>{{ states('sensor.meteo_type')
}}</font><br/><b>Beskrivelse</b></font> <br><font color= #4caf50>{{
state_attr('binary_sensor.meteoalarm','description') }}</font><br/>
<b>Start</b> <font color= #4caf50>{{
as_timestamp(state_attr('binary_sensor.meteoalarm','onset')) |
timestamp_custom('%A %X - %x') }}</font><br/><b>Slut</b> <font color=
#4caf50> {{
as_timestamp(state_attr('binary_sensor.meteoalarm','expires')) |
timestamp_custom('%A %X - %x') }}</font>
type: markdown
conditions:
- entity: binary_sensor.meteoalarm
state: 'on'
type: conditional
I know, it looks terrible here due to all the HTML formatting, the output looks like this: