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

Hi all :wave:

I just started building a custom integration for the Royal Meteorological Institute of Belgium (https://www.meteo.be). It uses their undocumented Android API to get the data.

You can find the repository here: GitHub - jdejaegh/irm-kmi-ha: Home Assistant weather provider using data from Belgian IRM KMI 🇧🇪 🇱🇺 🇳🇱

You will have to add the repository as a custom repository in HACS. Here is how to do it: Custom Repositories | HACS

As of version 0.2.6, the integration provides the following:

  • A weather entity with current weather conditions
  • Weather forecasts (hourly, daily and twice-daily) using the service weather.get_forecasts
  • A camera entity for rain radar and short-term rain previsions
  • A binary sensor for weather warnings
  • Sensors for pollen levels

This is my first integration for Home Assistant so feel free to share constructive feedback

14 Likes

Hi @jdejaegh
Great work on this integration!

Some feedback/questions:

  • The minimal temperature on the current day is never shown (see screenshot)
    image

  • The custom weather card (GitHub - bramkragten/weather-card: Weather Card with animated icons for Home Assistant Lovelace) does not show any forecast for KMI (only current weather). This very much could be due to this specific lovelace card, but since other weather integrations have the forecast visible on this card, I thought I’d mention it. What card do you use?

  • Any plans/possibility to include the “rain in 30 minutes” graph from the native app?

1 Like

Thanks for the feedback!

  • The missing minimal temperature is due to the way the data from KMI is sent. In the app, for the current day, there is no mention of the minimal temperature: it is in tonight’s forecast. To overcome this, the lowest temperature for the night will be shown as the lowest for the current day as well. I just committed those changes, it will be in the next release.
  • I use the default Lovelace card for testing the UI. I’ll have a look at the one you mentioned and see if I can make it work. They probably use some deprecated methods I did not implement.

  • The “rain in 30 minutes” graph is not sent as an image from KMI, only as data points (forecast and forecast margin). It is up to the app to render it nicely. I don’t yet if I will have time to figure it out soon.

1 Like

Fantastic!

I am now trying to read the hourly forecast in node-red.
But i can only see the current weather conditions.
Am i missing something?

Previously, the weather entity had an attribute forecast with a list of the future forecasts. In 2023.9, a service was introduced to replace that attribute: weather.get_forecasts. This lets you select the kind of forecast you want to get (hourly, daily or twice_daily), where the old forecast attribute would list all of them in a beautiful mess.

@DeBaerNils, to get the hourly forecast, use a service call like:

service: weather.get_forecasts
target:
  entity_id:
    - weather.home
data:
  type: hourly

@MichaelT, I looked at the card you linked. The issue is that they rely on the old forecast attribute. Currently, my integration does not implement that attribute as it is deprecated and only kept for backward compatibility.

I tried to put all the forecasts (daily and hourly) in the deprecated forecast attribute, but the custom card cannot tell which is daily or hourly. This is a known issue for the custom card.

As probably other old components still rely on the forecast attribute, I can offer a setup option to populate it with either the hourly or daily forecasts. This way, the custom card and other components relying on this can have the data they need.

Edit: it is now possible to use the old forecast attribute (as of version 0.1.6-beta)

Thanks for looking into this! I’ll update to the new release tomorrow.

Works great!

1 Like

I just released version 0.1.7-beta which adds support for the short-term rain forecast graph. Here is what it looks like (the image is not animated here, but is animated in HA).

@MichaelT you seemed interested in this feature.

I had to re-implement the graph rendering feature here as the graph is not sent as an image by the API. Thus, it may differ a bit from the original UI.

It introduces changes to the way the camera is implemented, if you face issues, please let me know (here or with a GitHub issue).

I did a quick test of the animation on these platforms:

  • Desktop Chromium-based browsers (like Chrome, Edge, Opera, etc.): works fine
  • Desktop Firefox-based browser: works fine
  • Android phone (mid-range specs from 2020) HA app: works fine
  • Android phone Firefox visiting web UI: flaky animation

What follows is a brief overview of how the implementation changed with this version. (You can safely skip this if don’t care :slight_smile:)

Before this version:

  • Every frame was a PNG, sent every 0.3 s to the client
  • The server had to burn all the layers (background map, clouds, location marker) into each frame
  • With 30 frames, it would take 4-7 seconds for the server, on each weather update
  • Client had an easy job: showing PNG

With this version

  • All the images are embedded in a single SVG file (background map, clouds, location marker)
  • The display of the different images is timed with SVG attributes to create the animation
  • The graph is fully vector vector-based and the white vertical line is animated at the same pace as the clouds
  • The server “just” has to embed the images in the SVG and draw the graph (< 1 second) on weather update
  • The client has to render the animated SVG (requires more CPU resources than PNG)
1 Like

I couldn’t do this with a call service but I managed to make it work by using the “API” node.
Thanks for leading me in the right direction.

For those interested:

[{“id”:“44be6abe51315453”,“type”:“ha-api”,“z”:“777f7153b5872de3”,“name”:“”,“server”:“d02ea838.224ec8”,“version”:1,“debugenabled”:false,“protocol”:“websocket”,“method”:“get”,“path”:“”,“data”:" {\t "type": "execute_script",\t "sequence": [\t {\t "service": "weather.get_forecasts",\t "data": {\t "type": "hourly"\t },\t "target": {\t "entity_id": [\t "weather.thuis"\t ]\t },\t "response_variable": "service_result"\t },\t {\t "stop": "done",\t "response_variable": "service_result"\t }\t ]\t}“,“dataType”:“jsonata”,“responseType”:“json”,“outputProperties”:[{“property”:“payload”,“propertyType”:“msg”,“value”:”",“valueType”:“results”}],“x”:610,“y”:820,“wires”:[[“c9f5d92ea706558d”]]},{“id”:“d02ea838.224ec8”,“type”:“server”,“name”:“Home Assistant”,“addon”:true}]

1 Like

not found in hacs integration … release 2023.12.4

It is not in HACS by default. You have to add repository of the integration in your custom repositories using HACS.

To do so, go to HACS on your Home Assistant instance, then select “Integrations”. In the top right, you have the three dots menu: select “custom repositories”. Add https://github.com/jdejaegh/irm-kmi-ha for the URL and “Integration” for the type

very nice integration, and for the Belgian users a lot more accurate than the Dutch ‘buienradar’. The installation went perfect.

One question:

when I go to the weather entity and ask the history, it shows the cloudy, fog, sunny, …

Is it possible to have the temperature in the history instead of the weather condition ?

Thanks for the cool integration!
After installing using HACS (and restarting Home Assistant), when I try to add the integration, it first says “Please wait, starting configuration wizard for irm_kmi” and then after a while I get this error:
image
Any clue why?

@FrankDC: glad you find this useful.

The weather entity will always have the weather condition as state so this is what will be saved to your history. However, you can create a new template sensor for the attribute you want to have in your history (e.g. temperature).

One way is to do the following: go to Settings > Devices & services > Helpers (on top ribbon) > Create Helper (bottom right) > Template > Template a sensor. There you can create a new sensor to get your temperature (see the screenshot). This will add an entity called sensor.home_temperature and its history will be saved. Repeat this for every other attribute you want to have in your history.

Credit to How to get temperature from a template - #2 by Brett_C for the idea.

I could have created many such sensors in the integration, but it adds many sensors that are not always useful. With the template, you can create whatever sensor you want or need.

@quizzical I don’t have any clue about this one, sorry. From the screenshot, it seems like an internal error of Home Assistant (this is not code I wrote). I never encountered this error during development and testing. Seems similar to Error when starting HACS intergration Reolink.

Could you provide a bit more insights?

  • What kind of Home Assistant setup do you run? OS, supervised, container, other?
  • Do you have logs of this error?
  • What version of Home Assistant and the integration are you running?
  • What are the steps to reproduce the error?

Thanks for the insights on my error.
I tried multiple times and had the error every time. This morning however when I tried again everything worked fine.
So probably it has nothing to do with your custom integration…
Case closed :⁠-⁠)
(I run the full home assistant stack on a virtual machine, using the latest version of home assistant and your integration. To produce the error I installed first trough hacs and then when trying to add it in the integrations section I got the error. But all fine now.)

1 Like

Your code doesn’t work, I’m pretty sure because the forum transformed some elements (you can paste it as code to avoid this). I managed to reconstruct your code (which is very useful thanks!). Here it is:

[{"id":"1ca3b8275e453020","type":"ha-api","z":"34843a6c.50d986","name":"naam","server":"5c29d263.09d2ac","version":1,"debugenabled":false,"protocol":"websocket","method":"get","path":"","data":"{\t   \"type\": \"execute_script\",\t   \"sequence\": [\t       {\t           \"service\": \"weather.get_forecasts\",\t           \"data\": {\"type\": \"hourly\"},\t           \"target\": {\t               \"entity_id\": [\"weather.huis_2\"]\t           },\t           \"response_variable\": \"service_result\"\t       },\t       {\t           \"stop\": \"done\",\t           \"response_variable\": \"service_result\"\t       }\t   ]\t}","dataType":"jsonata","responseType":"json","outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"results"}],"x":1330,"y":5780,"wires":[["15905ee7b853e1e6"]]},{"id":"a09ab2afbf59d121","type":"inject","z":"34843a6c.50d986","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":1200,"y":5780,"wires":[["1ca3b8275e453020"]]},{"id":"15905ee7b853e1e6","type":"debug","z":"34843a6c.50d986","name":"debug 105","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1470,"y":5780,"wires":[]},{"id":"5c29d263.09d2ac","type":"server","name":"Home Assistant","version":5,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":false,"cacheJson":true,"heartbeat":false,"heartbeatInterval":30,"areaSelector":"friendlyName","deviceSelector":"friendlyName","entitySelector":"friendlyName","statusSeparator":"at: ","statusYear":"hidden","statusMonth":"short","statusDay":"numeric","statusHourCycle":"h23","statusTimeFormat":"h:m","enableGlobalContextStore":true}]

You did a great work, thank you! Considering the current weather, I think it would maybe be more accurate to place this icon into the “partlycloudy” category.

image

Thanks for trying the integration!

Regarding the current weather, in the early versions of the integration, this icon was mapped to partly_cloudy. I changed it to sunny for the following reasons:

  • The weather outside, when this icon is in the IRM app, was mainly sunny: the only clouds were very light at high altitudes (you had to look for them to notice them)
  • The forecast text in the app, when this icon is shown for a future day, generally mentions a sunny day

Overall, I feel like the current categories represent quite well the outside weather. I agree that the categories are a bit subjective and they may change in the future if there is a general consensus for an update

Hello,
it works like a charm, thanks.

Hi thanks a lot for the integration!
I’m really glad you did it as the IRM/KMI is really sharp in its forecast in Belgium…

I have a question, what card do you use to display the radar and rain information?

Thx!

1 Like