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

You need to install it through HACS

Still got the same card?

Try with the standard type: weather-forecast card.

  1. try without the stack in card
  2. check you weather integration settings

Open your Home Assistant instance and show your integrations.

There are settings in the integration → configuration about the type of forecast you want.

Still no change. I got the KMI one.

Hi,
Would it be possible that you can help me set this up from scratch? I have absolutely no idea how to create custom cards ect.
Kind regards

I have a sensor outside for the current temperature.
Anyone knows if it’s possible to show this KMI information combined with the current temperature from another sensor?

Edit: the answer seems to be here, I just have to find how to fill that “forecast_daily_template” variable with KMI data.

Hi Jules,

Awesome integration, exactly what I was hoping to find and more!
Integrated nicely on my dashboard, with own weather station information. (Also added the kmi link to it, so that if I click on it, I go straight to the KMI site for more detail.)

Now that it has effectively replaced the KMI app…I wanted to see if I could use the data.

Use case : I am trying to figure out different way to maximize my solar power and my batteries. 1 such battery runs as UPS for my home network (including the server running HA).
If I charge the battery during night time or during sunny hours, I can save money during day hours when the price is high. So, I want to figure out: Do I unload charge in the morning, or afternoon.

So I went ahead and tried to write my very first template, which of course didn’t work. So, since you’ve been so incredibly helpful to others, I thought I’d put mine here too.

the idea : get the weather condition for next 10 hrs and see if I get a sunscore of 4. Where 1hr sunny = 1 and 1hr partlycloudy=1/2.

template:
  - trigger:
      - platform: state
        entity_id: weather.home
      - platform: homeassistant
        event: start
	  - platform: time_pattern
		hours: 1
    action:
      - service: weather.get_forecasts
        data:
          type: hourly
        target:
          entity_id: weather.home
        response_variable: hourly
    sensor:
      - name: Sunny in next 10 hour
        unique_id: q_sunny_today
        state: >
		  {% set counter = 0 %}
		  {% set counter2 = 0 %}
		  {% set status = false %}
		  {% set lstcondition = {{ hourly['weather.home'].forecast[:10].condition | map(attribute='precipitation')}} %} 
		  {%- for i in lstcondition if i= "sunny" -%}
		    {{ counter + 1 }}
		    {% if loop.length >= 4 and loop.first -%}
			  true
			{% endif -%}
		  {%- endfor-%}
		  {%- for i in lstcondition if i= "partlycloudy" -%}
		    {{ counter2 + 1 }}
		    {% if loop.length >= 8 and loop.first -%}
			  true
			{% endif -%}
		  {%- endfor-%}
		  {% if counter + (counter2/2) >= 4 %}
		    true
		  {% endif %} 

When pasting just the code in template editor, it gave me this as error:

TemplateSyntaxError: expected token ‘:’, got ‘}’

Which of course doesn’t tell me much, as I don’t even know which line number.

hi @jdejaegh

i tried your solution for the daily rain but it always says unknown. any idea why it could be like that?

Hi Kraganov,

Thanks for the feedback! I wasn’t checking the forum that much recently, but here is my take on your template. Note that I don’t use templates that much either, so there is probably a smarter way to do it :slight_smile:

  • Your template is misusing the {{ ... }} construction: sometimes omitting it, sometimes needlessly putting it.
  • The map(attribute='precipitation') is probably not what you want if you want to check if it is sunny or partlycloudy. You probably want to use map(attribute='condition').
  • = and == are two different operators: the first assigns a value, and the second checks for equality. In a condition, you generally want to use ==. Your template is using if i= "sunny".

The logic seems fine. The template syntax is a bit error-prone with the different constructs. ChatGPT is generally able to spot those syntax errors and mistakes (it helped me on this one).

Below is the updated code (keeping your logic). You can find the visual difference here: template-diff - Diffchecker

Updated code
template:
  - trigger:
      - platform: state
        entity_id: weather.home
      - platform: homeassistant
        event: start
      - platform: time_pattern
        hours: 1
    action:
      - service: weather.get_forecasts
        data:
          type: hourly
        target:
          entity_id: weather.home
        response_variable: hourly
    sensor:
      - name: Sunny in next 10 hour
        unique_id: q_sunny_today
        state: >
          {% set counter = 0 %}
          {% set counter2 = 0 %}
          {% set status = false %}
          {% set lstcondition = hourly['weather.home'].forecast[:10] | map(attribute='condition') | list %}
          {%- for i in lstcondition if i == "sunny" -%}
            {% set counter = counter + 1 %}
            {% if loop.length >= 4 and loop.first %}
              {{ true }}
            {% endif %}
          {%- endfor -%}
          {%- for i in lstcondition if i == "partlycloudy" -%}
            {% set counter2 = counter2 + 1 %}
            {% if loop.length >= 8 and loop.first %}
              {{ true }}
            {% endif %}
          {%- endfor -%}
          {% if counter + (counter2 / 2) >= 4 %}
            {{ true }}
          {% else %}
            {{ false }}
          {% endif %}

Note that you can probably do it with fewer lines and a more expressive syntax. Here is how:

template:
  - trigger:
      - platform: state
        entity_id: weather.home
      - platform: homeassistant
        event: start
      - platform: time_pattern
        hours: 1
    action:
      - service: weather.get_forecasts
        data:
          type: hourly
        target:
          entity_id: weather.home
        response_variable: hourly
    sensor:
      - name: Sunny in next 10 hours
        unique_id: q_sunny_today
        state: >
          {% set forecast = hourly['weather.home'].forecast[:10] %}
          {% set sunny = forecast | selectattr('condition', 'equalto', 'sunny') | list %}
          {% set partlycloudy = forecast | selectattr('condition', 'equalto', 'partlycloudy') | list %}
          {% set score = sunny | length + (partlycloudy | length) / 2 %}
          {{ score >= 4 }}

It builds three lists: forecast with the 10 next hourly forecasts, sunny with the sunny forecasts from the first list, and partlycloudy with the partly cloudy forecasts from the first list. It then computes the score as you specified (1 point for each sunny element, 0.5 for each partly cloudy) and returns true when the score is 4 or more.

Here again ChatGPT helped to rewrite the template and made it easier to understand. ChatGPT is not the best for all the tasks related to Home Assistant but for some it can help quite a bit :slight_smile:

Hope this helped!

1 Like

Hi,

Could you be more specific with regard to what you tried exactly? A link to the solution you mentioned or the code you used would help to understand the context.

Nice!! I love this solution! So elegant!

I will have to test this and see how this works out…but today I’m not free to test (or go look for the links you asked). Update will follow the coming week.

1 Like

Hi @jdejaegh,

Had to do some editing in Studio Code to not get syntax errors, but after I did those changes, it did get updated. (Note that when reloading config, it didn’t show issues, but the value also remained unavailable)

Corrected Config
  • trigger:
    • trigger: state
      entity_id: weather.home
    • trigger: homeassistant
      event: start
    • trigger: time_pattern
      hours: “1”
      action:
    • action: weather.get_forecasts
      data:
      type: hourly
      target:
      entity_id: weather.home
      response_variable: hourly
      sensor:
    • name: Sunny in next 10 hours
      unique_id: q_sunny_today
      state: >
      {% set forecast = hourly[‘weather.home’].forecast[:10] %}
      {% set sunny = forecast | selectattr(‘condition’, ‘equalto’, ‘sunny’) | list %}
      {% set partlycloudy = forecast | selectattr(‘condition’, ‘equalto’, ‘partlycloudy’) | list %}
      {% set score = sunny | length + (partlycloudy | length) / 2 %}
      {{ score >= 4 }}

The first result did come out correctly as false. Will need to monitor it a couple days, but I suspect this does work exactly as advertised. Thanks a lot for the assistance.

Note to self: Maybe I need to start using ChatGPT every now and then :laughing:

1 Like

Status update: The sensor is working pretty well and capturing the changing status pretty nicely :

Interesting use case! I wonder whether it’s more accurate than Forecast.Solar or Solcast PV Forecast. Do you use them and if so, have you compared the outcomes?

Just wanted to share my take on a pollen widget. It has large symbols in the color given by the API (if it has any) and hides them if they’re not active. The whole widget hides if no pollen are active. Right now I only included the tree pollen in it, as those are the only ones that matter for me, but you can easily adde the grass pollen as well. It uses the card-mod plugin.

type: entity-filter
conditions:
  - condition: state
    state_not: none
card:
  type: glance
  show_name: true
  show_icon: true
  show_state: false
  card_mod:
    style: |
      ha-card {
        --mdc-icon-size: 40px;
      }
entities:
  - entity: sensor.home_birch_level
    name: Berk
    card_mod:
      style: |
        :host {
          --card-mod-icon-color: {{ states(config.entity) }}
        }
  - entity: sensor.home_alder_level
    name: Els
    card_mod:
      style: |
        :host {
          --card-mod-icon-color: {{ states(config.entity) }}
        }
  - entity: sensor.home_oak_level
    name: Eik
  - entity: sensor.home_ash_level
    name: Es
  - entity: sensor.home_hazel_level
    name: Hazelaar
visibility:
  - condition: or
    conditions:
      - condition: state
        entity: sensor.home_birch_level
        state_not: none
      - condition: state
        entity: sensor.home_oak_level
        state_not: none
      - condition: state
        entity: sensor.home_alder_level
        state_not: none
      - condition: state
        entity: sensor.home_ash_level
        state_not: none
      - condition: state
        entity: sensor.home_hazel_level
        state_not: none