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.
| Service | Why |
|---|---|
weather.get_forecasts | it 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/
| Field | Type | Wire key | Description |
|---|---|---|---|
ApparentTemperature | *float64 | apparent_temperature | Apparent temperature. |
CloudCoverage | *float64 | cloud_coverage | Cloud coverage. |
DewPoint | *float64 | dew_point | Dew point temperature. |
Humidity | *float64 | humidity | Humidity. |
Ozone | *float64 | ozone | Ozone. |
PrecipitationUnit | *string | precipitation_unit | Precipitation unit. |
Pressure | *float64 | pressure | Pressure. |
PressureUnit | *string | pressure_unit | Pressure unit. |
SupportedFeatures | Feature | supported_features | A set of Feature flags. |
Temperature | *float64 | temperature | Temperature. |
TemperatureUnit | *string | temperature_unit | Temperature unit. |
UvIndex | *float64 | uv_index | UV index. |
Visibility | *float64 | visibility | Visibility. |
VisibilityUnit | *string | visibility_unit | Visibility unit. |
WindBearing | any | wind_bearing | Wind bearing. |
WindGustSpeed | *float64 | wind_gust_speed | Wind gust speed. |
WindSpeed | *float64 | wind_speed | Wind speed. |
WindSpeedUnit | *string | wind_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.
| Constant | Value |
|---|---|
FeatureUnknown | 0 |
FeatureForecastDaily | 1 << 0 |
FeatureForecastHourly | 1 << 1 |
FeatureForecastTwiceDaily | 1 << 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/
| Field | Type | Wire key | Description |
|---|---|---|---|
ApparentTemperature | *float64 | apparent_temperature | |
CloudCoverage | *int | cloud_coverage | |
Condition | *string | condition | |
Datetime | string | datetime | |
DewPoint | *float64 | dew_point | |
Humidity | *float64 | humidity | |
IsDaytime | *bool | is_daytime | |
Precipitation | *float64 | precipitation | |
PrecipitationProbability | *int | precipitation_probability | |
Pressure | *float64 | pressure | |
Temperature | *float64 | temperature | |
Templow | *float64 | templow | |
UvIndex | *float64 | uv_index | |
WindBearing | any | wind_bearing | |
WindGustSpeed | *float64 | wind_gust_speed | |
WindSpeed | *float64 | wind_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.
| Constant | Value |
|---|---|
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.