oh-my-posh/website/docs/segments/owm.mdx
Matthew Miller ed8d89a7cc feat: update Open Weather Map to use Geocoding API
Updated the Open Weather Map Current Weather URL to remove the
deprecated query parameter. Updated the URL to add the supported
latitude and longitude parameters.

Added a call to the Open Wetaher Map Geocoding API to resolve the
location parameter to latitude and longitude values as specified in the
Open Weather Map documentation.

Added properties to the Open Weather Map segment to allow users to
manually specify the latitude and longitude if desired. Doing this will
skip the geocoding API call and ignore the location parameter.

Updated the website documentation for the Open Weather Map segment to
reflect the property changes and explain how to use them.
2023-05-21 15:01:06 +02:00

75 lines
4.2 KiB
Plaintext

---
id: owm
title: Open Weather Map
sidebar_label: Open Weather Map
---
## What
Shows the current weather of a given location with [Open Weather Map][owm].
:::caution
You **must** request an API key at the [Open Weather Map][owm-price] website.
The free tier for _Current weather and forecasts collection_ is sufficient.
:::
## Sample Configuration
import Config from '@site/src/components/Config.js';
<Config data={{
"type": "owm",
"style": "powerline",
"powerline_symbol": "\uE0B0",
"foreground": "#ffffff",
"background": "#FF0000",
"template": "{{.Weather}} ({{.Temperature}}{{.UnitIcon}})",
"properties": {
"apikey": "<YOUR_API_KEY>",
"location": "AMSTERDAM,NL",
"units": "metric",
"http_timeout": 20,
"cache_timeout": 10
}
}}/>
## Properties
| Name | Type | Description |
| --------------- | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `apikey` | `string` | Your API key from [Open Weather Map][owm] |
| `latitude` | `float64` | The latitude of the requested location. |
| `longitude` | `float64` | The longitude of the requested location. |
| `location` | `string` | The requested location. Formatted as <City,STATE,COUNTRY_CODE>. City name, state code and country code divided by comma. Please, refer to ISO 3166 for the state codes or country codes - defaults to `DE BILT,NL` |
| `units` | `string` | Units of measurement. Available values are standard (kelvin), metric (celsius), and imperial (fahrenheit) - defaults to `standard` |
| `http_timeout` | `int` | The default timeout for http request is 20ms. |
| `cache_timeout` | `int` | The default timeout for request caching is 10m. A value of 0 disables the cache. |
| `template` | `string` | A go [text/template][go-text-template] template extended with [sprig][sprig] utilizing the properties below - defaults to `{{.Weather}} ({{.Temperature}}{{.UnitIcon}})` |
### Specifying Location
The given location can either be specified through the Latitude and Longitude properties or through the Location property. If both Latitude and Longitude are specified and valid then Location will be ignored if it is included. If Latitude or Longitude are not specified or are invalid then Location will be used.
## Template ([info][templates])
:::note default template
```template
{{ .Weather }} ({{ .Temperature }}{{ .UnitIcon }})
```
:::
### Properties
| Name | Type | Description |
| -------------- | -------- | ---------------------------------------------- |
| `.Weather` | `string` | the current weather icon |
| `.Temperature` | `int` | the current temperature |
| `.UnitIcon` | `string` | the current unit icon(based on units property) |
| `.URL` | `string` | the url of the current api call |
[templates]: /docs/configuration/templates
[owm]: https://openweathermap.org
[owm-price]: https://openweathermap.org/price