Skip to main content

MetService smart home integration, free and open source

MetService integration for Gladys Assistant

Official New Zealand weather by MetService: hourly forecast per town, today and tomorrow.

The official weather of New Zealand in Gladys: the hourly forecast of MetService for the towns you follow, read through the MetService Point Forecast API (run by MetOcean Solutions, a MetService company). For anyone with a home, a bach or family in New Zealand.

Developed without an API key: feedback welcome. The integration follows the API documentation and was tested against the live service for what needs no key (the endpoint, the refused key), not with a real forecast. Please report what works and what does not in the issues.

This integration is not affiliated with MetService nor with MetOcean.

Presentation​

  • One device per town: up to five of the 43 towns and cities MetService publishes a local forecast for, from Kaitaia to Invercargill.
  • Each device shows, for the hour in progress: temperature, feels-like temperature, humidity, air pressure, wind speed, gusts and direction, precipitation (mm/h) and the conditions (fine, partly cloudy, rain
); and the minimum and maximum of today and tomorrow.
  • A scene trigger Rain expected: rain is forecast within the next 3 hours.
  • A scene action Get the MetService forecast: today's or tomorrow's forecast as scene variables, ready for a message.
  • A dashboard widget MetService forecast: live values, the coming hours, today and tomorrow.
  • Read-only: nothing can be controlled.

Prerequisites​

  • Gladys Assistant 5.3.0 or later (catalog countries; widgets and scene cards since 5.1.0).
  • A MetService Point Forecast API key: create an account on console.metoceanapi.com, then copy the key from Usage & keys. The free plan is for non-commercial use and includes a monthly amount of API units; check it in the console, and set a usage limit there so that nothing is ever charged.
  • Internet access for Gladys (the integration calls forecast-v2.metoceanapi.com).

Why not the forecasts of the metservice.com website? Their data says it "may only be used with explicit permission from MetService": the integration uses the official API instead.

Configuration​

Open Integrations → MetService → Configuration.

API key​

Paste the key of the console. It stays in the Gladys configuration: it is never written in the logs nor under /data.

Towns​

Pick the towns to follow, five at most: each one becomes a device in Discovery. The forecast is asked for the centre of the town (rounded to about 1 km).

Refresh and API units​

Each request costs 8 API units per town (8 weather variables), whatever the number of hours it returns. One request brings the hourly forecast from midnight today to midnight after tomorrow (New Zealand time); between two requests, the values move on by themselves every hour. So a long interval costs little and loses little:

IntervalUnits a month, per town
15 min23,040
30 min11,520
1 hour5,760
2 hours2,880 (default)
3 hours1,920
6 hours960

The Test the connection button shows the estimate for your configuration. The forecast models behind the API are updated a few times a day: below one hour, the gain is small.

Language​

The language of the feature names of new devices (fixed at their creation), of the conditions and of the scene action texts. French by default.

Devices​

FeatureTypeUnit
Temperaturetemperature°C
Feels liketemperature°C
Humidityhumidity%
Air pressure (sea level)pressurehPa
Wind speed, wind gustsspeedkm/h
Wind direction (where it comes from)angle°
Precipitationprecipitationmm/h
Conditionstext
Today minimum / maximumtemperature (min, max)°C
Tomorrow minimum / maximumtemperature (min, max)°C

All values are forecasts of the model for the hour in progress, not station observations. The feels-like temperature is the apparent temperature (Steadman), from temperature, humidity and wind. The conditions come from the precipitation rate and the cloud cover.

Widget​

Add the MetService forecast widget to a dashboard and pick a town. It shows the conditions, the temperature, the feels-like temperature, the wind and the rain, then the coming hours (every 3 hours) and today and tomorrow (min / max, rain, strongest gust). Each of the last two blocks can be hidden in the widget settings. Showing the widget never spends a request.

Scene trigger​

Rain expected fires once when the forecast starts showing rain (0.5 mm/h or more) within the next 3 hours, after a dry forecast; it fires again only after a dry spell. Filter: the town. Variables: town, starts_at (ISO date), minutes (before the rain), rate (strongest rate, mm/h), horizon_hours. It is evaluated every minute on the forecast already received.

Scene action​

Get the MetService forecast (town, today or tomorrow) returns, for the following actions: summary (a ready sentence, in the configured language), conditions, min, max (°C), rain (mm over the day) and gust (km/h). It reads the forecast already received: no request. Example: every morning at 7:00, Get the MetService forecast for today, then send summary on Telegram.

Scene examples​

  • Rain expected in Auckland → notify "Rain in {{minutes}} min: bring the washing in".
  • Every evening, Get the MetService forecast for tomorrow → if min is below 3, notify a frost risk.
  • When Wind gusts exceed 90 km/h → close the awning.

Troubleshooting​

  • "MetService refused the API key": check the key in the console (no space), and that it is active.
  • "MetService refused the request" (HTTP 402/403): the plan of the key, or its usage limit, does not allow it; check Usage & keys in the console.
  • "Too many MetService requests" (HTTP 429): every request stops for one hour.
  • "MetService does not answer": the forecasts resume as soon as it does; the values already received keep moving on in the meantime, up to midnight after tomorrow.
  • No value on a device: add it in Discovery first; the values arrive right away.
  • Logs: Integrations → MetService → Logs; LOG_LEVEL=debug shows each request.

Limits​

  • Forecasts only: the integration does not read the observations of MetService weather stations.
  • No MetService severe weather warnings: the Point Forecast API does not carry them.
  • The conditions are computed from rain and cloud cover: no thunderstorm, fog or hail.
  • 43 towns, five at most: no free coordinates.
  • Developed without an API key (see above): the units of each variable are converted from what the API says in its answer; an unknown unit is skipped and logged, never published wrong.

Configuration settings​

These are the settings MetService asks for in its configuration screen in Gladys.

SettingTypeRequiredDescription
Getting startedsectionNoThe forecasts come from the MetService Point Forecast API (MetOcean, a MetService company). Create an account on console.metoceanapi.com and copy your API key: the free plan is for non-commercial use and includes a monthly amount of API units. Each request costs 8 units per town. Not affiliated with MetService.
Point Forecast API keysecretYesThe key shown in "Usage & keys" of console.metoceanapi.com.
Townsmulti_selectYesThe MetService towns and cities to follow, five at most: one device each.
Refresh intervalselectNoTime between two requests per town. Between requests, the hourly forecast already received moves on by itself.
Language of the textsselectNoFeature names of new devices, conditions and the texts of the scene action.

How to install MetService in Gladys​

  1. In Gladys, open Integrations: MetService appears in the catalog, next to the native integrations, with a community badge.
  2. Click Install. Gladys pulls the Docker image (ghcr.io/guim31/gladys-metservice:1.0.0), starts it in a sandbox isolated from the core, and generates the integration's interface (devices, discovery and configuration).
  3. Open the Configuration screen of the integration, fill in the settings, and save.
  4. You can also install it directly from its repository URL: https://github.com/guim31/gladys-metservice.

MetService requires Gladys >=5.3.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​

MetService 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.

Subscribe to the Gladys Assistant newsletter

A few emails per month about new releases and project news. Sent by Pierre-Gilles Leymarie, founder of the project. Unsubscribe anytime 🙂