Belgium weather provider: IRM / KMI (meteo.be)

Maybe not the most efficient …
You do need the hourly sensor defined (mine is called sensor.forecast_kmi_hourly) and the time-slots are min 1 hour.
Below looks at the next 3 hours. If you just want 1 hour replace the 3 with 1

          {% set begin = (now() + timedelta(hours=1)).strftime('%Y-%m-%d %H') %}
          {% set end = (now() + timedelta(hours=3)).strftime('%Y-%m-%d %H') %}

          {% set forecasts = state_attr('sensor.forecast_kmi_hourly', 'forecast') %}
          {% set rain_forecasts = forecasts | selectattr('datetime', 'ge', begin) | selectattr('datetime', 'le', end) | selectattr('precipitation', 'gt', 0 ) | list %}
          {% set total_rain = rain_forecasts | map(attribute='precipitation') | select('!=', 0) | map('float') | sum %}
              
          {{ total_rain | round(2) }}    

I really want to work with the data that comes in from the radar attribute. I need this to close my blinds a few minutes before it starts raining at an intensity above a certain threshold.

This is a temporary solution to avoid water coming into my bedroom. I still need to order new windows and there is a waiting period as well. This should help me a lot :slight_smile:

In case it can be useful for others, or be further optimized, here the way I managed to visualize the Pollen values with the custom Flex Table Card:

This is the yaml code of the card config. You only need to update the sensor filter in the include (use a * instead of the “pollen type” in the sensor and it will select all sensors at once.

type: custom:flex-table-card
title: Pollen
entities:
  include: sensor.xxx_*_level
columns:
  - name: Type
    data: friendly_name
    align: center
    modify: x.split(" ")[1];
  - name: None
    data: state
    align: center
    modify: |-
      if (x == 'none')
        '<ha-icon icon="mdi:flower-pollen">'
      else
        ''
  - name: Active
    data: state
    align: center
    modify: |-
      if (x == 'active')
        '<ha-icon icon="mdi:flower-pollen">'
      else
        ''
  - name: Green
    data: state
    align: center
    modify: |-
      if (x == 'green')
        '<ha-icon icon="mdi:flower-pollen">'
      else
        ''
  - name: Yellow
    data: state
    align: center
    modify: |-
      if (x == 'yellow')
        '<ha-icon icon="mdi:flower-pollen">'
      else
        ''
  - name: Orange
    data: state
    align: center
    modify: |-
      if (x == 'orange')
        '<ha-icon icon="mdi:flower-pollen">'
      else
        ''
  - name: Red
    data: state
    align: center
    modify: |-
      if (x == 'red')
        '<ha-icon icon="mdi:flower-pollen">'
      else
        ''
  - name: Purple
    data: state
    align: center
    modify: |-
      if (x == 'purple')
        '<ha-icon icon="mdi:flower-pollen">'
      else
        ''
css:
  tbody tr td:nth-child(4): 'background-color: green;'
  tbody tr td:nth-child(5): 'background-color: yellow;'
  tbody tr td:nth-child(6): 'background-color: orange;'
  tbody tr td:nth-child(7): 'background-color: red;'
  tbody tr td:nth-child(8): 'background-color: purple;'

I know layout isn’t very good, not my strong suit, so if anyone wants to give it a go to further optimize, be my guest, but do share your results though :slight_smile:

Made a (for me) slightly better version where the width of the columns are a bit better, but dropped the column names for it (the colours say enough I guess):

This is the yaml code for the Card:

type: custom:flex-table-card
title: Pollen
entities:
  include: sensor.xxx_*_level
columns:
  - name: Type
    data: friendly_name
    align: center
    modify: x.split(" ")[1];
  - name: None
    data: state
    align: center
    modify: |-
      if (x == 'none')
        '<ha-icon icon="mdi:flower-pollen">'
      else
        ''
  - name: Active
    data: state
    align: center
    modify: |-
      if (x == 'active')
        '<ha-icon icon="mdi:flower-pollen">'
      else
        ''
  - name: ''
    data: state
    align: center
    modify: |-
      if (x == 'green')
        '<ha-icon icon="mdi:flower-pollen">'
      else
        ''
  - name: ''
    data: state
    align: center
    modify: |-
      if (x == 'yellow')
        '<ha-icon icon="mdi:flower-pollen">'
      else
        ''
  - name: ''
    data: state
    align: center
    modify: |-
      if (x == 'orange')
        '<ha-icon icon="mdi:flower-pollen">'
      else
        ''
  - name: ''
    data: state
    align: center
    modify: |-
      if (x == 'red')
        '<ha-icon icon="mdi:flower-pollen">'
      else
        ''
  - name: ''
    data: state
    align: center
    modify: |-
      if (x == 'purple')
        '<ha-icon icon="mdi:flower-pollen">'
      else
        ''
css:
  tbody tr td:nth-child(2): 'width: 32px'
  tbody tr td:nth-child(3): 'width: 32px'
  tbody tr td:nth-child(4): 'background-color: green; width: 32px'
  tbody tr td:nth-child(5): 'background-color: yellow; width: 32px'
  tbody tr td:nth-child(6): 'background-color: orange; width: 32px'
  tbody tr td:nth-child(7): 'background-color: red; width: 32px'
  tbody tr td:nth-child(8): 'background-color: purple; width: 32px'

Hope it’s useful for others

2 Likes

I stumbled upon this forum thread in my quest to create Definitive guide to Weather integrations 🌦

The integration seems to have very detailed allergy information, radar entity and weather alarm.
To my surprise, this was the first integration which implemented the “twice daily” weather forecast, but the data is incorrect. Also the state of the weather entity is unknown instead of showing the condition.

Regardless of the few small bugs, it looks like a usefull integration and a good contribution to the guide. It’s not ideal to have a sample size of one, to I wanted to ask for your input as well. It is usefull? Accurate? Stable?

Hi,
I am the author of the integration. Thanks for your feedback!

I am a bit surprised about the two issues you have with the integration. Could you elaborate a bit more: what makes you say that the twice daily forecast is incorrect? The state of the integration should be showing the current weather condition. Could you share your configuration?

Bugs are possible but I try to fix them whenever I can reproduce them. Here is what the weather entity should look like (from the GitHub repository)

Please note that the zone you set for the forecast should be in Belgium, Netherlands or Luxembourg to work properly.

I might be a bit biased about the integration, so I’ll rather share why I think this integration was missing from the Home Assistant ecosystem: the data from the IRM KMI (the Belgian meteorological institute) was not yet available in HA and many people use their app in Belgium (1M+ downloads on the Play Store). They provide daily, hourly and very short term forecast which may be useful for automation.

If you have more questions to list this integration in your linked post, feel free to ask :slight_smile:

Something something picture vs 1000 words…

I’m located in the Netherlands.

Most issues I encountered during testing weather integrations were related to my location / IP address.
The remaining issues varied from “common” to “rare” but hardly ever unique to my setup.

Thanks! You just helped me realize that the original IRM KMI app does not show the current condition for the Netherlands either. See the screenshots of their app: for Brussels it shows the temperature and condition next to the city name (19° cloudy) but it only shows the temperature for Amsterdam.

I’ll fix the missing condition by taking the one for the current hour forecast (14h hourly forecast in my screenshot)

For the repeating days in the twice daily forecast, I’ll fix the logic.


@AJediIAm The two bugs you mentioned should be fixed in the latest version (0.2.17)

I checked your guide for weather integrations and it is really complete, great job! You just made a small typo in the name of this integration (MRI KMI instead of IRM KMI at multiple places)

I’ll have a look at it later this week, but you are free to edit the post yourself to keep it correct and up to date. Everyone can edit guides and it is highly encouraged.

I cannot find the option to edit the guide: there is no pencil icon at the bottom of the post on my side. Here are the options I have at the bottom of your guide
image

Several other people made edits. How about at the top?

I (finally) fixed the typo’s btw

I see that others managed to edit but there’s no button when I go there either. Maybe my account level is not high enough yet. Anyway, thanks for fixing the typo

Ohw i really like this look, care to share your YAML for this? :slight_smile:

sure

This is what’s in the dashboard/lovelace yaml

              - type: markdown
                  title: Pollen
                  content: |-
                      <ha-alert alert-type="error">  {{ states ('sensor.my_kmi_pollen_hi') }}</ha-alert>
                      <ha-alert alert-type="warning">{{ states ('sensor.my_kmi_pollen_me') }}</ha-alert>
                      <ha-alert alert-type="info"   >{{ states ('sensor.my_kmi_pollen_lo') }}</ha-alert>

The sensors are built like this (ps: my kmi weather sensors have been renamed like sensor.forecast_kmi_alder_level )

  - name: my_kmi_pollen_lo      
    state: >
        {% set pollen = states 
            | select('search', 'kmi') 
            | select('search', 'level')
            | selectattr('state', 'eq', 'yellow')    
            | map(attribute='attributes.friendly_name')
            | list
            | join(', ')
            | replace ("Pollen ","")     
        %} 
        {{ pollen if pollen else '-' }}

  - name: my_kmi_pollen_me     
    state: >
        {% set pollen = states 
            | select('search', 'kmi') 
            | select('search', 'level')
            | selectattr('state', 'eq', 'orange')    
            | map(attribute='attributes.friendly_name')
            | list
            | join(', ')
            | replace ("Pollen ","")     
        %} 
        {{ pollen if pollen else '-' }}

  - name: my_kmi_pollen_hi
    state: >
        {% set pollen = states 
            | select('search', 'kmi') 
            | select('search', 'level')
            | selectattr ('state','in',['red','purple'])
            | map(attribute='attributes.friendly_name')
            | list
            | join(', ')
            | replace ("Pollen ","")     
        %} 
        {{ pollen if pollen else '-' }}

Made another iteration of this. I wanted to only show the ones that are actually active. To do that I had to use the custom “Auto Entities Card” (which the “Flex Table Card” also supports) to filter out the sensors with state “none”, but it does result in a cleaner table:

The yaml of the Cards look like this:

type: custom:auto-entities
filter:
  include:
    - entity_id: sensor.ev04_*_level
  exclude:
    - state: none
card:
  type: custom:flex-table-card
  title: Pollen
  columns:
    - name: Type
      data: friendly_name
      align: center
      modify: x.split(" ")[1];
    - name: Active
      data: state
      align: center
      modify: |-
        if (x == 'active')
          '<ha-icon icon="mdi:flower-pollen">'
        else
          ''
    - name: ''
      data: state
      align: center
      modify: |-
        if (x == 'green')
          '<ha-icon icon="mdi:flower-pollen">'
        else
          ''
    - name: ''
      data: state
      align: center
      modify: |-
        if (x == 'yellow')
          '<ha-icon icon="mdi:flower-pollen">'
        else
          ''
    - name: ''
      data: state
      align: center
      modify: |-
        if (x == 'orange')
          '<ha-icon icon="mdi:flower-pollen">'
        else
          ''
    - name: ''
      data: state
      align: center
      modify: |-
        if (x == 'red')
          '<ha-icon icon="mdi:flower-pollen">'
        else
          ''
    - name: ''
      data: state
      align: center
      modify: |-
        if (x == 'purple')
          '<ha-icon icon="mdi:flower-pollen">'
        else
          ''
  css:
    tbody tr td:nth-child(1): 'width: 32px'
    tbody tr td:nth-child(2): 'width: 32px'
    tbody tr td:nth-child(3): 'background-color: green; width: 32px'
    tbody tr td:nth-child(4): 'background-color: yellow; width: 32px'
    tbody tr td:nth-child(5): 'background-color: orange; width: 32px'
    tbody tr td:nth-child(6): 'background-color: red; width: 32px'
    tbody tr td:nth-child(7): 'background-color: purple; width: 32px'
2 Likes

Anyone can explain me how to set forecast value in attribute ?
And how to get the data for the next day ?

Thanks

Well I was looking at the IRM/KMI Open data site for an api and while searching stumble on this !
Great ! Let’s try!

And it works ! So thanks !

1 Like

The author of this issue shared its template sensor for this: Problem pasing daily forecast · Issue #49 · jdejaegh/irm-kmi-ha · GitHub. There are other topics discussing this exact matter on this forum as it is common to all weather integrations (e.g. Update from using weather attributes with the new service: weather.get_forecasts)

Using the service weather.get_forecasts (Weather - Home Assistant) will return the forecast for the next days (or hours). Using templates like the one share just above may help you getting it in an attribute if this is what you are looking for.

The IRM/KMI open data is kind of frustrating to me: they either have really specific datasets open to the public or interesting datasets but not open to the public.

Example of the first kind is the Weather Model Alaro, which include this warning

[The charts] aren’t corrected or interpreted by the forecasters of the RMI. A correct interpretation of these charts requires some expertise.

Their non-public datasets include Hourly Commune Forecast, which seems perfect for this integration, but “This product is not publically available.”

They are probably selling their non-public data to paid customers, which makes sense as that data is their core business.

That’s why this integration is not using their open data, rather it uses the API of their mobile application. It has some limitations, but already provides good data points.