Custom FMI (Finnish Meteorological Institute) Weather & Sensor Platform

Custom weather and sensor platform that extracts weather data from Finnish Meteorological Institute (FMI) Open-Data API (https://en.ilmatieteenlaitos.fi/open-data).

Platforms

Currently this supports Weather and Sensor platforms.
Sensor platform also provides a type Best Time of the Day, based on user preferences that can perhaps be used to trigger notifications for outdoor activities.

Installation Instructions

Code Repository

Do give this a shot and let me know your feedback.

5 Likes

Just installed and looks good! Great stuff. I’m planning on integrating this with my automower to avoid unnecessary mowing when likelihood of rain is high. And as a Finn this info is definitely more reliable than Dark Sky or other platforms. So highly appreciated!

Couple of questions though; when you use this yourself do you get same forecast data from the fmi platform that you get from Ilmatieteenlaitos.fi? I’m getting different hourly forecast for some reason … though the location might be the key here as the web page is not per my latitude/longitude but the general area I would assume.

Secondly more related to the weather platform; any idea how to extract the forecast attributes? I would be interested in picking up the forecasted condition but as there are multiple in the attributes I dont really have a clue how to formulate the template.With quick search on Google came up short.

Thanks!!

I also noticed that Ilmatieteenlaitos.fi observations/forecast differ from the one available via their Open-Data API. I am not sure if it’s due to the location or if it’s due to the frequency of forecast data updated at this API. On their web page it says forecast models are updated more than once per day, but that’s the only detail I could find. Probably the web service has more frequent updates than the Open-Data API.

The weather sensor produces an array of forecast objects. One possible template example to extract today’s condition and temperature for an action, could be:

{% for forecast in state_attr("weather.fmi", "forecast") %}
  {% if forecast.datetime.day == now().day %} 
    Condition is {{ forecast.condition }} and temperature is {{ forecast.temperature }}
    {% if forecast.temperature > 15 %}
      Do something!!
    {% endif %}
  {% endif %}
{% endfor %}

If I try this in Developer Tools --> Template Editor, I get:

Condition is sunny and temperature is 17.5
      Do something!!

Hope this helps!

Thanks, appreciate this a lot!

Hi Anand,

Do you see it feasible to add an attribute to the FMI sensor of the distance to closest lightning strike based on the location set - and when that occured? I understood that FMI has the the data but not sure if its there in the same db that you pull this forecast info from?

Hi,

I am not sure if that information is available in the forecast database. However there are some other stores too. I will check and get back.

Regards,
Anand.

Hi,

Finally I got some time to get this working. Please check the latest commit. I tested this with current HASS version and develop branch and it works fine. Do let me know if you face any issues.

Regards,
Anand.

Hi,

I can’t seem to get this to work. I’ve downloaded the files under /custom_components/fmi and added the example sensor config to configuration.yaml (also tried the weather platform, same results).

Home Assistant says “Platform error sensor.fmi - Integration ‘fmi’ not found.”

Any ideas? Tried multiple restarts.

I’m running Home Assistant Supervised, version 0.114.4.

Hi,

I have 0.115 and not seeing any issues. Do you have the detailed logs, that shows some kind of tracepath? One of the constant values - UNIT_PERCENTAGE was replaced with PERCENTAGE in the core hass module. This was a breaking change which made fmi non-functional in 0.115. That was fixed in latest fmi version to get it working for 0.115. I believe this is what is causing the issue in your environment.

It may be a good idea to upgrade to 0.115, or else I can try to avoid the core hass dependency to make this backwards compatible. That may take some time. Let’s see.

Hi,

I upgraded to the newest version, no help there :S

Here’s a paste from the HA logs section:

Logger: homeassistant.setup
Source: custom_components/fmi/__init__.py:171
First occurred: September 24, 2020, 9:22:24 PM (1 occurrences)
Last logged: September 24, 2020, 9:22:24 PM

Error during setup of component fmi
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/setup.py", line 213, in _async_setup_component
    result = await task
  File "/config/custom_components/fmi/__init__.py", line 171, in async_setup
    for index, entity in enumerate(config[DOMAIN], start=0):
KeyError: 'fmi'

When I downloaded the master.zip and unzipped it to the /fmi directory, the zip had a directory inside it. I removed that and the files are directly under /fmi. Is this okay?

I have a feeling that this is a really stupid user error, but my knowledge of these custom integrations are close to none and therefore can’t avoid those errors :smile:

Hi,
I have version 0.115.2

I removed the existing directory under custom_components and performed the same steps as you did:

  1. Download fmi-hass-custom-master.zip
  2. Unzip all files into fmi diretory under custom_components. This is how it looks finally:
anandpr@anandpr-HP-ZBook-15-G3:/usr/share/hassio/homeassistant/custom_components/fmi$ ls -lhrt
total 60K
-rwxr--r-- 1 root root 4,2K syys   22 23:30 weather.py
-rwxr--r-- 1 root root  14K syys   22 23:30 sensor.py
-rwxr--r-- 1 root root 5,7K syys   22 23:30 README.md
-rwxr--r-- 1 root root  241 syys   22 23:30 manifest.json
-rwxr--r-- 1 root root 1,1K syys   22 23:30 LICENSE
-rwxr--r-- 1 root root  12K syys   22 23:30 __init__.py
-rwxr--r-- 1 root root 2,5K syys   22 23:30 const.py
drwxr-xr-x 2 root root 4,0K syys   27 18:46 __pycache__
anandpr@anandpr-HP-ZBook-15-G3:/usr/share/hassio/homeassistant/custom_components/fmi$
  1. Perform a hass restart or even better a host restart.

In my case, home assistant is running as a docker container on a ubuntu host. I m not seeing error logs as shown above.

Hi and thanks for FMI integration. I’ve installed as told and end result looks just like it should. However sensor platform is not updating? I think it worked in 2020.12 but not sure since last value keeps on for a while.
Now I’m running 20.10.2 and weather works fine but sensors not?
image image

@vesatakomo: Thanks for trying this out! There was a bug in the refresh calls. And I am not sure what changed between the releases, but it requires a manual call to the update functions now. Either way I have tested this now and seems to be working fine. Please do try the latest version and let me know how it goes.

Hi Anand,
Sorry took some time but now I’ve updated and followed values. Everything seems to be working great.
I’ll put these sensors in good use. :slight_smile:

1 Like

Hello!

Thanks for creating this integration!

To get the integration added, I had to install geopy module. Not sure if this was the right way to go, but what I did was (on freebsd host):

cd /usr/local/share/homeassistant/
/usr/local/bin/bash
python3.8 -m venv .
source ./bin/activate
pip3.8 install geopy

With that done, seems to work great!

1 Like

@KossiKenguru
Thanks for trying this and sorry for the late response!

geopy is needed for reverse geocoding the location of closest lightning strike. So what you did seems to be right.

Regards,
Anand.

@anand-p-r thanks for this! This is far more accurate here in Finland than other weather integrations for sure.

1 Like

@anand-p-r I installed this today and it’s working fine. One question though: by default, it’s showing the hourly forecast. I would like to see daily forecast (like the default integration does). How can I change that? I’m using this with the Weather Forecast card.

Another question: may I now completely remove the Met.no integration?

1 Like

Hi @Jay_Jay: You can find the FMI integration under the Configuration → Integrations page. On the FMI card, there is a link that says OPTIONS. Click that and you will find a menu to update forecast interval and other goodies as well.
However if you choose the forecast interval as 24hrs, by default the FMI python client library that this integration uses, only fetches the forecast for the next 2 days. Hope this helps.

1 Like

How come I didn’t notice that. Thanks!