Skip to content

Module thc_OpenWeatherMap

Andreas Drollinger edited this page Nov 8, 2019 · 11 revisions

OpenWeatherMap

Introduction and setup

The thc_OpenWeatherMap module implements THC devices that get data from the OpenWeatherMap site. A registration is required to use the OpenWeatherMap service. The API key obtained during the registration process needs to be declared with the thc::OpenWeatherMap::Configure command.

To get weather data you need first to know a location recognized by OpenWeatherMap. The location can either be defined via the city name, the city ID or by the geographic coordinates. Validate the location on the OpenWeatherMap website: <http://www.openweathermap.org/find?q=x>

The following current weather parameters are available :

  • sunrise - Sunrise time, decimal, UTC
  • sunset - Sunset time, decimal, UTC
  • temp - Temperature, Celsius
  • humidity - Humidity, %
  • pressure - Atmospheric pressure (on the sea level)
  • speed - Wind speed, km/h
  • dir - Wind direction, degrees (meteorological)

The definition of an OpenWeatherMap devices requires the declaration of the 'get' command, using the following syntax:

 {thc_OpenWeatherMap {<Location> <WeatherParameter>}}

Examples

 thc::OpenWeatherMap::Configure \
    -api_key 1234567890abcd

 thc::DefineDevice Bern,temp \
    -name Bern -group Environment -format "%sC" -range {-30 50} -update 10m \
    -get {thc_OpenWeatherMap {"Bern,ch" "temp"}}

Proc: thc::OpenWeatherMap::Configure

Configures the OpenWeatherMap access.

Parameters

Parameters Description
[-api_key <API_Key>] OpenWeatherMap API Key.

Returns

-

Examples

 thc::OpenWeatherMap::Configure \
    -api_key 1234567890abcd