SMHI smart home integration, free and open source

Official SMHI weather for Sweden and the Nordics: current values, forecasts, warnings.
Official weather forecasts of the Swedish Meteorological and Hydrological Institute (SMHI) in Gladys: current values, hour-by-hour and day-by-day forecasts, and the SMHI weather warnings for Sweden. Public data, no account, no API key.
Not affiliated with SMHI. Developed without a live test against SMHI: feedback welcome on the Gladys forum.
What the integration does
- One device per place: each Gladys house that has a location, plus, optionally, a place given by its coordinates (a cottage, a boat harbour…).
- Current weather of the place, refreshed every 30 minutes: temperature, feels-like temperature, humidity, pressure, wind (mean, gusts, direction), cloud cover, precipitation (intensity and type), visibility, thunder probability and the weather in words.
- SMHI weather warnings (yellow, orange, red) whose area covers the place, as a level Gladys scenes can compare, a text, and a scene trigger.
- A dashboard widget with the next 24 hours and the coming days.
- A scene action that reads one day of the forecast (today, tomorrow, the day after) for a morning message or a frost alert.
The forecast covers the area of the SMHI model: the Nordic countries and the Baltic region (Sweden, Norway, Finland, Denmark, the Baltic states and the seas around them). The warnings only exist for Sweden and its waters.
Requirements
- Gladys Assistant 5.1.0 or later.
- Gladys must reach
opendata-download-metfcst.smhi.seandopendata-download-warnings.smhi.seover HTTPS. - For the houses: a location set in Settings → Houses of Gladys.
Installation
- In Gladys, open Integrations → Install from GitHub and enter
https://github.com/guim31/gladys-smhi, or install SMHI from the store. - Accept the access to the location of the houses: it is used to ask SMHI for the forecast of each house, nothing else.
- Open the Discovery tab of the integration and add the devices of the places you want.
Configuration
| Field | Default | Use |
|---|---|---|
| Forecast for the houses | on | One device per house that has a location in Gladys. |
| Other place: latitude | empty | Decimal degrees (59.3293, a comma works too). Empty: the houses only. |
| Other place: longitude | empty | Decimal degrees, east positive (18.0686). |
| Other place: name | SMHI | Name of the device of that place. |
| County for the warnings | Automatic | Automatic: the warnings whose drawn area contains the place. |
| Refresh interval | 30 min | 15 min, 30 min or 1 hour. SMHI updates its forecast about once an hour. |
| Language | French | Names of the features of new devices, weather and warning texts, summaries. |
Choosing a county also keeps every warning that touches the county, even when its drawn area does not contain the place: useful near the edge of an area, at the cost of warnings for the other end of the county.
The feature names are fixed when the device is added: change the language first, then add the devices.
The device of a place
| Feature | Unit | Notes |
|---|---|---|
| Temperature | °C | Air temperature at 2 m. |
| Feels like | °C | Computed (Steadman formula: temperature, humidity, wind). |
| Humidity | % | Relative humidity. |
| Pressure | hPa | At mean sea level. |
| Wind speed | m/s | Mean wind at 10 m. |
| Wind gusts | m/s | |
| Wind direction | ° | Where the wind comes from (0 north, 90 east). |
| Cloud cover | % | Share of the sky covered. |
| Precipitation | mm/h | Mean intensity of the hour. |
| Precipitation type | text | Rain, snow, sleet, drizzle… "No precipitation" when nothing falls. |
| Visibility | km | |
| Thunder probability | % | |
| Weather | text | The SMHI weather symbol in words (Overcast, Light rain…). |
| Warning level | 0 to 3 | 0 none, 1 yellow, 2 orange, 3 red: the highest warning of the place. |
| Warnings | text | The warnings in progress, the highest first, with the end of the first. |
All features are read-only. The values are those of the forecast for the hour in progress: SMHI publishes a model forecast, not the measurements of a weather station. Gladys converts temperature, speed and distance to the units of each user.
Dashboard widget
Add the SMHI forecast widget to a dashboard and choose the place (the first one when none is chosen). It shows the weather in words and the time of the last reading, the temperature, the feels-like temperature and the wind, a curve of the next 24 hours, the warnings in progress and six days (weather, minimum and maximum temperature, precipitation). It follows the language and the units of the user.
Scene trigger: new SMHI weather warning
Fires when SMHI issues a warning whose area covers a place, or raises the
level of a warning in progress (yellow to orange…). Filters: the place, the
levels. Variables for the next actions: the level (yellow, orange,
red), the event, the area, the description, the start and the end. SMHI
writes events and descriptions in Swedish and English: the integration passes
the English ones.
A warning is announced once: neither a new reading nor a restart of the integration fires the trigger again for the same warning at the same level.
Scene action: read the SMHI forecast
Choose the place and the day (today, tomorrow, the day after). The action returns, for the next actions of the scene: the minimum and maximum temperature (°C), the precipitation (mm), the strongest gust (m/s), the highest thunder probability (%), the weather in words, and a summary sentence in the language of the configuration.
Configuration action: check the forecast
The Check the forecast button asks SMHI now for every place, added or not, and shows the answer: temperature, weather and warning level, or the reason of a failure (place outside the forecast area, SMHI not answering).
Scene examples
- Morning message: at 7:00, Read the SMHI forecast (today), then send the summary output to the family by message.
- Frost alert: at 18:00, Read the SMHI forecast (tomorrow); if the minimum temperature is below 0, send "Cover the plants tonight".
- Storm warning: trigger New SMHI weather warning with the orange and red levels, then send the event and the description, and close the awning.
- Thunder: when Thunder probability goes above 50 %, turn off the sensitive equipment.
Refresh and quotas
The integration refreshes by itself, at the chosen interval (30 minutes by default), even when Gladys does not poll the device. Each refresh makes one request per added place and one for the warnings (the whole of Sweden at once). Places whose device was not added are never read, except by the Check the forecast button. SMHI publishes no quota for its open data and updates its model about once an hour: a shorter interval brings nothing. The data are published by SMHI under the Creative Commons Attribution 4.0 licence.
Troubleshooting
- "No location": no house of Gladys has a location, and no coordinates are entered. Set the location of a house (Settings → Houses), or enter a latitude and a longitude.
- "The coordinates cannot be read": enter decimal degrees, such as
59.3293and18.0686, not degrees and minutes. - "Outside the SMHI forecast area": the place is outside the area of the SMHI model (the Nordic and Baltic countries). Another integration is needed there.
- "SMHI does not answer": Gladys cannot reach SMHI (network, DNS, SMHI down). The last forecast is kept while it covers the present, and a new try follows at the next refresh.
- No warning while SMHI shows one: the drawn area of the warning may not contain the exact point of the place. Choose your county in County for the warnings.
- More details: set
LOG_LEVEL=debugon the integration to see every reading in its logs.
Limits
- A forecast, not a measurement: the values come from the SMHI model for the nearest point of its grid (about 2.5 km).
- The warnings cover Sweden only; their texts are in English.
- The feature names and the device names are fixed when the device is added.
- No UV index, no pollen, no fire risk: SMHI publishes them elsewhere.
- Changing the coordinates of the other place creates a new device (a new place has its own history).
Credits and licence
Data: © SMHI, Creative Commons Attribution 4.0. The reading of the API follows
the Home Assistant smhi integration and the pysmhi library by G Johansson
(MIT). Integration under the Apache 2.0 licence. Not affiliated with SMHI.
Configuration settings
These are the settings SMHI asks for in its configuration screen in Gladys.
| Setting | Type | Required | Description |
|---|---|---|---|
| SMHI forecasts | section | No | Forecasts of the Swedish Meteorological and Hydrological Institute (SMHI) for the Nordic and Baltic countries, and its weather warnings for Sweden. Public data, no account. One device per place: each Gladys house with a location, and the coordinates entered below. Not affiliated with SMHI. |
| Forecast for the Gladys houses | boolean | No | One device per house that has a location in Gladys (Settings → Houses). |
| Other place: latitude | string | No | Decimal degrees, a comma is accepted. Leave empty for the houses only. |
| Other place: longitude | string | No | Decimal degrees, east positive. |
| Other place: name | string | No | Name of its device, SMHI when empty. |
| County for the warnings | select | No | Automatic: the warnings whose area contains the place. A county: also every warning touching it. |
| Refresh interval | select | No | SMHI updates its forecast about once an hour. |
| Language of the names and texts | select | No | Feature names of new devices, weather and warning texts, scene action summary. |
How to install SMHI in Gladys
- In Gladys, open Integrations: SMHI appears in the catalog, next to the native integrations, with a community badge.
- Click Install. Gladys pulls the Docker image (
ghcr.io/guim31/gladys-smhi:1.0.1), starts it in a sandbox isolated from the core, and generates the integration's interface (devices, discovery and configuration). - Open the Configuration screen of the integration, fill in the settings, and save.
- You can also install it directly from its repository URL: https://github.com/guim31/gladys-smhi.
SMHI requires Gladys >=5.1.0. The catalog inside Gladys refreshes every hour, so a new version becomes available at most one hour after its release.
Not running Gladys yet? It is free and open source: follow the installation guide to get started.
About external integrations
SMHI is an external integration: a community integration packaged as a Docker container and published on GitHub, that Gladys installs in one click and runs in a sandbox isolated from its core. It is published and maintained by guim31, not by the Gladys core team.
- Browse all integrations, native and community
- Build and publish your own external integration
- Source code on GitHub — source of this documentation