Getting a two day weather forecast
- benhaguenz
- May 22, 2021
- 2 min read
OpenWeathermap.org have an API that allows you to request a weather forecast for any where in the world. The Swagger definition I'm using is:
swagger: '2.0'
info: {title: Open Weather, description: '', version: '1.0'}
host: api.openweathermap.org
basePath: /data/2.5
schemes: [https]
consumes: []
produces: []
paths:
/onecall:
get:
responses:
default:
description: default
schema:
type: object
properties:
lat: {type: number, format: float, description: lat}
lon: {type: number, format: float, description: lon}
timezone: {type: string, description: timezone}
timezone_offset: {type: integer, format: int32, description: timezone_offset}
hourly:
type: array
items:
type: object
properties:
dt: {type: integer, format: int32, description: dt}
temp: {type: number, format: float, description: temp}
feels_like: {type: number, format: float, description: feels_like}
pressure: {type: integer, format: int32, description: pressure}
humidity: {type: integer, format: int32, description: humidity}
dew_point: {type: number, format: float, description: dew_point}
uvi: {type: number, format: float, description: uvi}
clouds: {type: integer, format: int32, description: clouds}
visibility: {type: integer, format: int32, description: visibility}
wind_speed: {type: number, format: float, description: wind_speed}
wind_deg: {type: integer, format: int32, description: wind_deg}
wind_gust: {type: number, format: float, description: wind_gust}
weather:
type: array
items:
type: object
properties:
id: {type: integer, format: int32, description: id}
main: {type: string, description: main}
description: {type: string, description: description}
icon: {type: string, description: icon}
description: weather
pop: {type: number, format: float, description: pop}
rain:
type: object
properties:
1h: {type: number, format: float, description: 1h}
description: rain
description: hourly
operationId: GetWeather
summary: Gets latest weather forecast
parameters:
- {name: lat, in: query, required: true, type: string}
- {name: lon, in: query, required: true, type: string}
- {name: appid, in: query, required: true, type: string}
- in: query
name: exclude
required: false
type: array
items: {type: string}
- {name: units, in: query, required: false, type: string}
description: Gets a weather forecast from OpenWeather
definitions: {}
parameters: {}
responses: {}
securityDefinitions: {}
security: []
tags: []
The flow looks like:

Excluding everything except the hourly forecast.

To add a newline to an adaptive card you need to append two returns, so the break line variables look empty but there's actually a single carriage return in each.


The time conversion is timestamp to GMT to NZT via:
convertTimeZone(addSeconds('1970-1-1',variables('timestamp')),'Greenwich Standard Time','New Zealand Standard Time','yyyy-MM-dd-HH:mm')

Comments