weather

Go types for Home Assistant's weather domain: control over HTTP.

Control: HTTP
import "github.com/taumatix/homeassistant-go/domains/weather"

Overview

Package weather is Home Assistant's weather domain: its types.

Entity controls one weather entity over HTTP.

No method for weather.get_forecasts, which only answer with data: call api.Client.CallServiceForResponse.

Home Assistant documents the domain here:

Integration: https://www.home-assistant.io/integrations/weather/

Entity model (developers): https://contributors.home-assistant.io/core/entities/weather/

Control

// client is an *api.Client
target := weather.Get(client, "my_weather")
state, err := target.State(ctx)

Commands

Services without a method

Call these with the REST or WebSocket client.

ServiceWhy
weather.get_forecastsit only answers with data

Control

type Entity struct

Entity controls one weather entity over HTTP (api.Client). State and Subscribe come from the embedded Handle.

Embeds entity.Handle[Attributes], whose methods it has too.

func Get(transport entity.Transport, id string) *Entity

Get returns the weather entity with the given id: an entity id over HTTP (the "weather." prefix may be omitted). It does no I/O.

func List(ctx context.Context, transport entity.Transport) ([]*Entity, error)

List returns every weather entity the transport can see.

type State = entity.State[Attributes]

State is a snapshot of one weather entity.

State and values

type Attributes struct

Attributes are the state attributes of a weather entity, under the names Home Assistant publishes them with.

See: https://www.home-assistant.io/integrations/weather/

FieldTypeWire keyDescription
ApparentTemperature*float64apparent_temperature

Apparent temperature.

CloudCoverage*float64cloud_coverage

Cloud coverage.

DewPoint*float64dew_point

Dew point temperature.

Humidity*float64humidity

Humidity.

Ozone*float64ozone

Ozone.

PrecipitationUnit*stringprecipitation_unit

Precipitation unit.

Pressure*float64pressure

Pressure.

PressureUnit*stringpressure_unit

Pressure unit.

SupportedFeaturesFeaturesupported_features

A set of Feature flags.

Temperature*float64temperature

Temperature.

TemperatureUnit*stringtemperature_unit

Temperature unit.

UvIndex*float64uv_index

UV index.

Visibility*float64visibility

Visibility.

VisibilityUnit*stringvisibility_unit

Visibility unit.

WindBearinganywind_bearing

Wind bearing.

WindGustSpeed*float64wind_gust_speed

Wind gust speed.

WindSpeed*float64wind_speed

Wind speed.

WindSpeedUnit*stringwind_speed_unit

Wind speed unit.

Feature

type Feature uint64

Feature is a set of weather supported features, with the values of core's WeatherEntityFeature: the supported_features attribute decodes into it.

ConstantValue
FeatureUnknown0
FeatureForecastDaily1 << 0
FeatureForecastHourly1 << 1
FeatureForecastTwiceDaily1 << 2
func FeatureFromString(s string) Feature

FeatureFromString returns the Feature spelled s, by its value or by the name of core's member, and FeatureUnknown for anything else.

type Forecast struct

Forecast is core's Forecast.

See: https://www.home-assistant.io/integrations/weather/

FieldTypeWire keyDescription
ApparentTemperature*float64apparent_temperature
CloudCoverage*intcloud_coverage
Condition*stringcondition
Datetimestringdatetime
DewPoint*float64dew_point
Humidity*float64humidity
IsDaytime*boolis_daytime
Precipitation*float64precipitation
PrecipitationProbability*intprecipitation_probability
Pressure*float64pressure
Temperature*float64temperature
Templow*float64templow
UvIndex*float64uv_index
WindBearinganywind_bearing
WindGustSpeed*float64wind_gust_speed
WindSpeed*float64wind_speed

StateValue

type StateValue string

StateValue lists the built-in values of the entity state, as Home Assistant translates them. Integrations may use others, which are kept as they are.

ConstantValue
StateValueUnknown"Unknown"
StateValueClearNight"clear-night"
StateValueCloudy"cloudy"
StateValueExceptional"exceptional"
StateValueFog"fog"
StateValueHail"hail"
StateValueLightning"lightning"
StateValueLightningRainy"lightning-rainy"
StateValuePartlycloudy"partlycloudy"
StateValuePouring"pouring"
StateValueRainy"rainy"
StateValueSnowy"snowy"
StateValueSnowyRainy"snowy-rainy"
StateValueSunny"sunny"
StateValueWindy"windy"
StateValueWindyVariant"windy-variant"
func StateValueFromString(s string) StateValue

StateValueFromString returns s as a StateValue.

func (v *StateValue) UnmarshalJSON(data []byte) error

UnmarshalJSON reads any spelling StateValueFromString accepts.