weather_owm

package
v0.13.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 2, 2024 License: GPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// EntityWeatherOwm ...
	EntityWeatherOwm = string("weather_owm")
	// DefaultApiUrl ...
	DefaultApiUrl = "https://api.openweathermap.org/data/2.5/onecall"
	// Attribution ...
	Attribution = "Weather forecast from openweathermap api"
	// FuncEntityAction ...
	FuncEntityAction = "entityAction"

	Version = "0.0.1"
)
View Source
const (
	// AttrAppid ...
	AttrAppid = "appid"
	// AttrUnits ...
	AttrUnits = "units"
	// AttrLang ...
	AttrLang = "lang"
)
View Source
const (
	// Name ...
	Name = "weather_owm"
)

Variables

This section is empty.

Functions

func New

func New() supervisor.Pluggable

New ...

func NewSettings

func NewSettings() map[string]*m.Attribute

NewSettings ...

func WeatherCondition

func WeatherCondition(w ProductWeather) (state supervisor.ActorState)

"id": 500, "main": "Rain", "description": "небольшой дождь", "icon": "10d"

Types

type Actor added in v0.9.0

type Actor struct {
	supervisor.BaseActor
	Zone
	// contains filtered or unexported fields
}

Actor ...

func NewActor added in v0.9.0

func NewActor(entity *m.Entity,
	service supervisor.Service) *Actor

NewActor ...

func (*Actor) Destroy added in v0.12.0

func (e *Actor) Destroy()

func (*Actor) SetState added in v0.9.0

func (e *Actor) SetState(params supervisor.EntityStateParams) error

SetState ...

func (*Actor) Spawn added in v0.9.0

func (e *Actor) Spawn()

Spawn ...

type Alert

type Alert struct {
	SenderName  string   `json:"sender_name"` // Name of the alert source
	Event       string   `json:"event"`       // Alert event name
	Start       int64    `json:"start"`       // Date and time of the start of the alert, Unix, UTC
	End         int64    `json:"end"`         // Date and time of the end of the alert, Unix, UTC
	Description string   `json:"description"` // Description of the alert
	Tags        []string `json:"tags"`        // Type of severe weather
}

Alert ...

type City

type City struct {
	Id         int64  `json:"id"`         // City ID
	Name       string `json:"name"`       // City name
	Coord      GeoPos `json:"coord"`      // City geo location
	Country    string `json:"country"`    // Country code (GB, JP etc.)
	Population int64  `json:"population"` //
	Timezone   int64  `json:"timezone"`   // Shift in seconds from UTC
	Sunrise    int64  `json:"sunrise"`    // Sunrise time
	Sunset     int64  `json:"sunset"`     // Sunset time
}

City ...

type GeoPos

type GeoPos struct {
	Lat float64 `json:"lat"` // latitude
	Lon float64 `json:"lon"` // longitude
}

GeoPos ...

type Product

type Product struct {
	Dt         int64          `json:"dt"`         // Time of data forecasted, unix, UTC
	Visibility int64          `json:"visibility"` // Average visibility, metres
	Pop        float64        `json:"pop"`        //  Probability of precipitation
	Main       ProductMain    `json:"main"`
	Weather    ProductWeather `json:"weather"`
	Clouds     *ProductClouds `json:"clouds,omitempty"`
	Wind       *ProductWind   `json:"wind,omitempty"`
	Rain       *ProductRain   `json:"rain,omitempty"`
	Snow       *ProductSnow   `json:"snow,omitempty"`
	Sys        *ProductSys    `json:"sys,omitempty"`
	DtTxt      time.Time      `json:"dt_txt"`
}

Product ...

type ProductClouds

type ProductClouds struct {
	All int64 `json:"all"` // Cloudiness, %
}

ProductClouds ...

type ProductMain

type ProductMain struct {
	Temp      float64 `json:"temp"`       // Temperature. Unit Default: Kelvin, Metric: Celsius, Imperial: Fahrenheit.
	FeelsLike float64 `json:"feels_like"` // This temperature parameter accounts for the human perception of weather. Unit Default: Kelvin, Metric: Celsius, Imperial: Fahrenheit.
	TempMin   float64 `json:"temp_min"`   // Minimum temperature at the moment of calculation. This is minimal forecasted temperature (within large megalopolises and urban areas), use this parameter optionally. Unit Default: Kelvin, Metric: Celsius, Imperial: Fahrenheit.
	TempMax   float64 `json:"temp_max"`   // Maximum temperature at the moment of calculation. This is maximal forecasted temperature (within large megalopolises and urban areas), use this parameter optionally. Unit Default: Kelvin, Metric: Celsius, Imperial: Fahrenheit.
	Pressure  float64 `json:"pressure"`   // Atmospheric pressure on the sea level by default, hPa
	SeaLevel  float64 `json:"sea_level"`  // Atmospheric pressure on the sea level, hPa
	GrndLevel float64 `json:"grnd_level"` // Atmospheric pressure on the ground level, hPa
	Humidity  float64 `json:"humidity"`   // Humidity, %
	TempKf    float64 `json:"temp_kf"`    // Internal parameter
}

ProductMain ...

type ProductRain

type ProductRain struct {
	Last3Hours float64 `json:"3h"` // Rain volume for last 3 hours, mm
}

ProductRain ...

type ProductSnow

type ProductSnow struct {
	Last3Hours float64 `json:"3h"` // Snow volume for last 3 hours
}

ProductSnow ...

type ProductSys

type ProductSys struct {
	Pod string `json:"pod"` // Part of the day (n - night, d - day)
}

ProductSys ...

type ProductWeather

type ProductWeather struct {
	Id          int64  `json:"id"`          // Weather condition id
	Main        string `json:"main"`        // Group of weather parameters (Rain, Snow, Extreme etc.)
	Description string `json:"description"` // Weather condition within the group. You can get the output in your language.
	Icon        string `json:"icon"`        // Weather icon id
}

ProductWeather ...

type ProductWind

type ProductWind struct {
	Speed float64 `json:"speed"` // Wind speed. Unit Default: meter/sec, Metric: meter/sec, Imperial: miles/hour.
	Deg   float64 `json:"deg"`   // Wind direction, degrees (meteorological)
	Gust  float64 `json:"gust"`  // Wind gust. Unit Default: meter/sec, Metric: meter/sec, Imperial: miles/hour
}

ProductWind ...

type Products

type Products []Product

Products ...

func (Products) Len

func (p Products) Len() int

Len ...

func (Products) Less

func (p Products) Less(a, b int) bool

Less ...

func (Products) Swap

func (p Products) Swap(a, b int)

Swap ...

type WeatherCurrent

type WeatherCurrent struct {
	Dt         int64               `json:"dt"`                   // Current time, Unix, UTC
	Sunrise    int64               `json:"sunrise"`              // Sunrise time, Unix, UTC
	Sunset     int64               `json:"sunset"`               // Sunset time, Unix, UTC
	Temp       float64             `json:"temp"`                 // Temperature. Units - default: kelvin, metric: Celsius, imperial: Fahrenheit.
	FeelsLike  float64             `json:"feels_like"`           // Temperature. This temperature parameter accounts for the human perception of weather
	Pressure   float64             `json:"pressure"`             // Atmospheric pressure on the sea level, hPa
	Humidity   float64             `json:"humidity"`             // Humidity, %
	DewPoint   float64             `json:"dew_point"`            // Atmospheric temperature (varying according to pressure and humidity) below which water droplets begin to condense and dew can form.
	Uvi        float64             `json:"uvi"`                  // Current UV index
	Clouds     float64             `json:"clouds"`               // Cloudiness, %
	Visibility int64               `json:"visibility"`           // Average visibility, metres
	WindSpeed  float64             `json:"wind_speed,omitempty"` // Wind speed. Wind speed.
	WindDeg    float64             `json:"wind_deg,omitempty"`   // Wind direction, degrees (meteorological)
	WindGust   *float64            `json:"wind_gust,omitempty"`  // (where available) Wind gust.
	Rain       *WeatherCurrentRain `json:"rain"`                 //
	Snow       *WeatherCurrentSnow `json:"snow"`                 //
	Weather    []ProductWeather    `json:"weather"`              //
}

WeatherCurrent ...

type WeatherCurrentRain

type WeatherCurrentRain struct {
	LastHour float64 `json:"1h"` // Rain volume for last hour, mm
}

WeatherCurrentRain ...

type WeatherCurrentSnow

type WeatherCurrentSnow struct {
	LastHour float64 `json:"1h"` // Snow volume for last hour, mm
}

WeatherCurrentSnow ...

type WeatherDaily

type WeatherDaily struct {
	Dt         int64                 `json:"dt"`                   // Current time, Unix, UTC
	Sunrise    int64                 `json:"sunrise"`              // Sunrise time, Unix, UTC
	Sunset     int64                 `json:"sunset"`               // Sunset time, Unix, UTC
	Moonrise   int64                 `json:"moonrise"`             // The time of when the moon rises for this day, Unix, UTC
	Moonset    int64                 `json:"moonset"`              // The time of when the moon sets for this day, Unix, UTC
	MoonPhase  float64               `json:"moon_phase"`           // Moon phase. 0 and 1 are 'new moon', 0.25 is 'first quarter moon', 0.5 is 'full moon' and 0.75 is 'last quarter moon'. The periods in between are called 'waxing crescent', 'waxing gibous', 'waning gibous', and 'waning crescent', respectively.
	Temp       WeatherDailyTemp      `json:"temp"`                 // Temperature. Units - default: kelvin, metric: Celsius, imperial: Fahrenheit.
	FeelsLike  WeatherDailyFeelsLike `json:"feels_like"`           // Temperature. This temperature parameter accounts for the human perception of weather
	Pressure   int64                 `json:"pressure"`             // Atmospheric pressure on the sea level, hPa
	Humidity   float64               `json:"humidity"`             // Humidity, %
	DewPoint   float64               `json:"dew_point"`            // Atmospheric temperature (varying according to pressure and humidity) below which water droplets begin to condense and dew can form.
	Uvi        float64               `json:"uvi"`                  // Current UV index
	Clouds     float64               `json:"clouds"`               // Cloudiness, %
	Visibility float64               `json:"visibility"`           // Average visibility, metres
	WindSpeed  float64               `json:"wind_speed,omitempty"` // Wind speed. Wind speed.
	WindDeg    float64               `json:"wind_deg,omitempty"`   // Wind direction, degrees (meteorological)
	WindGust   *float64              `json:"wind_gust,omitempty"`  // (where available) Wind gust.
	Rain       float64               `json:"rain"`                 //
	Snow       float64               `json:"snow"`                 //
	Weather    []ProductWeather      `json:"weather"`              //
}

WeatherDaily ...

type WeatherDailyFeelsLike

type WeatherDailyFeelsLike struct {
	Day   float64 `json:"day"`
	Min   float64 `json:"min"`
	Max   float64 `json:"max"`
	Night float64 `json:"night"`
	Eve   float64 `json:"eve"` // Evening temperature.
	Morn  float64 `json:"morn"`
}

WeatherDailyFeelsLike ...

type WeatherDailyTemp

type WeatherDailyTemp struct {
	Day   float64 `json:"day"`
	Min   float64 `json:"min"`
	Max   float64 `json:"max"`
	Night float64 `json:"night"`
	Eve   float64 `json:"eve"` // Evening temperature.
	Morn  float64 `json:"morn"`
}

WeatherDailyTemp ...

type WeatherFor5Days

type WeatherFor5Days struct {
	Cod      string   `json:"cod"`     //  Internal parameter
	Message  int      `json:"message"` //  Internal parameter
	Cnt      int      `json:"cnt"`     //  A number of timestamps returned in the API response
	Products Products `json:"list"`
	City     City     `json:"city"`
}

WeatherFor5Days ...

type WeatherFor8Days

type WeatherFor8Days struct {
	GeoPos
	Timezone       string          `json:"timezone"`        // Timezone name for the requested location
	TimezoneOffset int64           `json:"timezone_offset"` // Shift in seconds from UTC
	Current        WeatherCurrent  `json:"current"`
	Hourly         []WeatherHourly `json:"hourly"`
	Daily          []WeatherDaily  `json:"daily"`
	Alerts         []Alert         `json:"alerts"`
}

WeatherFor8Days ...

type WeatherHourly

type WeatherHourly struct {
	Dt         int64               `json:"dt"`                   // Current time, Unix, UTC
	Temp       float64             `json:"temp"`                 // Temperature. Units - default: kelvin, metric: Celsius, imperial: Fahrenheit.
	FeelsLike  float64             `json:"feels_like"`           // Temperature. This temperature parameter accounts for the human perception of weather
	Pressure   float64             `json:"pressure"`             // Atmospheric pressure on the sea level, hPa
	Humidity   float64             `json:"humidity"`             // Humidity, %
	DewPoint   float64             `json:"dew_point"`            // Atmospheric temperature (varying according to pressure and humidity) below which water droplets begin to condense and dew can form.
	Uvi        float64             `json:"uvi"`                  // Current UV index
	Clouds     float64             `json:"clouds"`               // Cloudiness, %
	Visibility int64               `json:"visibility"`           // Average visibility, metres
	WindSpeed  float64             `json:"wind_speed,omitempty"` // Wind speed. Wind speed.
	WindDeg    float64             `json:"wind_deg,omitempty"`   // Wind direction, degrees (meteorological)
	WindGust   *float64            `json:"wind_gust,omitempty"`  // (where available) Wind gust.
	Rain       *WeatherCurrentRain `json:"rain"`                 //
	Snow       *WeatherCurrentSnow `json:"snow"`                 //
	Weather    []ProductWeather    `json:"weather"`              //
	Pop        float64             `json:"pop"`                  // Probability of precipitation
}

WeatherHourly ...

type WeatherOwm

type WeatherOwm struct {
	// contains filtered or unexported fields
}

WeatherOwm ...

func NewWeatherOwm

func NewWeatherOwm(adaptors *adaptors.Adaptors, crawler web.Crawler) (weather *WeatherOwm)

NewWeatherOwm ...

func (*WeatherOwm) FetchData

func (p *WeatherOwm) FetchData(name string, lat, lon float64, now time.Time, settings map[string]*m.Attribute) (zone Zone, err error)

FetchData ...

func (*WeatherOwm) GetForecast

func (p *WeatherOwm) GetForecast(params Zone, now time.Time, settings map[string]*m.Attribute) (forecast m.AttributeValue, err error)

GetForecast ...

func (*WeatherOwm) UpdateForecast

func (p *WeatherOwm) UpdateForecast(zone Zone, settings map[string]*m.Attribute) (forecast m.AttributeValue, err error)

UpdateForecast ...

type Zone

type Zone struct {
	Name        string           `json:"name"`
	Lat         float64          `json:"lat"`
	Lon         float64          `json:"lon"`
	Weatherdata *WeatherFor8Days `json:"weatherdata"`
	LoadedAt    *time.Time       `json:"loaded_at"`
}

Zone ...

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL