Setting up the meteo sensor and card

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.

  - platform: meteoalarm
    country: 'DK'
    language: 'da'
    province: 'København og Nordsjælland'
  - platform: template
        value_template: >
          {% set v = state_attr('binary_sensor.meteoalarm', 'event') %}
          {{ 'off' if v == none else v.split(" ")[1] }}
        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:

      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
      - 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:


You’ll need to use a list (containing Mandag, Tirsdag, Onsdag, etc) to convert the days-names.

1 Like

Thanks for the great example!
Hint for future users - as usual - don’t copy/paste from this forum directly to Lovelace, use an interim plain text editor. Saves a lot of trouble.

1 Like

I love this… thank you.

Is anyone finding the 1st 7 characters always missing from the description?

i.e. mine now starts “Gusty winds may lead to some travel” but in HA it is " inds may lead to some travel"

1 Like

No, mine looks normal.
What happens if you put

{{ state_attr('binary_sensor.meteoalarm','description') }}

In the template tester?

well there are no weather warnings right now, which is a shock for the north east of england :smiley:

but I could see yesterday that the meteo sensor was missing these characters in the description

Ok, then it must be a problem with the meteo system, it collects info from local agencies, and publish them under one roof.

Got it all in, but don´t get any information, even if I try to put in a place that has warningsSkærmbillede 2020-07-23 kl. 13.09.52

What does the sensor show in developer tools?

They just says off

If you click on the binary_sensor.meteoalarm it is probably not set to anything.
That could be because there is no alert, or because meteoalarm again is offline.

Ok, I`ll let It be and see when an alert shows up, thanks :blush:

1 Like