Documentation
¶
Overview ¶
Package ha holds the Home Assistant wire types shared by the transports and the domain packages: templates, icons, device details, availability, discovery references and a few enums the documentation has no table for.
The clients are in package api (REST and WebSocket) and package mqtt (MQTT). Each entity domain has a package under domains/ with its types, an Entity to control entities over either client, and a Device to serve one over MQTT. Package entity is the transport-neutral runtime behind them.
Index ¶
- Variables
- func FirstSet(fallback string, options ...*string) string
- func Must[T any](v T, err error) T
- func Or[T any](p *T, fallback T) T
- func P[T any](v T) *T
- func Strings[T ~string](values []T) []string
- func V[T any](p *T) T
- type Date
- type DateTime
- type DeviceDetails
- type DeviceOrigin
- type DeviceTrackerSourceType
- type Icon
- type MQTTAvailability
- type MQTTDeviceDetails
- type MQTTDiscoverySchema
- type MediaPlayerMediaClass
- type ObjectRef
- type SpeechToTextAudioBitRates
- type SpeechToTextAudioChannels
- type SpeechToTextAudioCodecs
- type SpeechToTextAudioFormats
- type SpeechToTextAudioSampleRates
- type Template
- type Time
- type TimeString
- type ToDoListTodoItemStatus
- type Unsubscribe
Constants ¶
This section is empty.
Variables ¶
var ErrNotSupportedOverMQTT = errors.New("not supported over MQTT")
ErrNotSupportedOverMQTT is returned by the Entity methods whose command has no MQTT representation (an action Home Assistant implements on its side).
Functions ¶
func FirstSet ¶
FirstSet returns the first of the optional strings which is set and not empty, or fallback: how Home Assistant reads an option with a stand-in, such as a switch's state_on, else its payload_on.
func Must ¶
Must panics on err and returns v otherwise. It is convenient for chaining calls in examples and tools.
func Or ¶
func Or[T any](p *T, fallback T) T
Or returns what p points to, or fallback when p is nil.
func P ¶
func P[T any](v T) *T
P returns a pointer to v. It is convenient for filling the many optional pointer fields of the generated configuration structs.
Types ¶
type Date ¶
Date is a simple date without time.
As the Time of a period, Start is the first instant of the day and End the last second of it.
func (*Date) MarshalJSON ¶
func (*Date) UnmarshalJSON ¶
type DateTime ¶
DateTime is a date and time.
The same time is used for both start and end
func (*DateTime) MarshalJSON ¶
func (*DateTime) UnmarshalJSON ¶
type DeviceDetails ¶
type DeviceDetails struct {
Identifiers []string `json:"identifiers"`
Name string `json:"name"`
Manufacturer string `json:"manufacturer"`
Model string `json:"model,omitempty"`
SwVersion string `json:"sw_version,omitempty"`
SerialNumber string `json:"serial_number,omitempty"`
HardwareVersion string `json:"hw_version,omitempty"`
}
type DeviceOrigin ¶
type DeviceTrackerSourceType ¶
type DeviceTrackerSourceType string
DeviceTrackerSourceType is how a device tracker learned its position.
const ( DeviceTrackerSourceTypeGPS DeviceTrackerSourceType = "gps" DeviceTrackerSourceTypeRouter DeviceTrackerSourceType = "router" DeviceTrackerSourceTypeBluetooth DeviceTrackerSourceType = "bluetooth" DeviceTrackerSourceTypeBluetoothLE DeviceTrackerSourceType = "bluetooth_le" )
The documented source types of a device tracker entity.
type Icon ¶
type Icon string
Icon is a Home Assistant icon name such as "mdi:lightbulb". Any string converts to it; the icons package has a constant for every known one. see: https://www.home-assistant.io/integrations/homeassistant/#icon
type MQTTAvailability ¶
type MQTTAvailability struct {
PayloadAvailable string `json:"payload_available,omitempty"`
PayloadNotAvailable string `json:"payload_not_available,omitempty"`
Topic string `json:"topic"`
ValueTemplate string `json:"value_template,omitempty"`
}
MQTTAvailability is one entry of an entity's availability list.
type MQTTDeviceDetails ¶
type MQTTDeviceDetails struct {
// Identifiers are the device's unique IDs; Home Assistant groups
// entities that share one. Mirrors DeviceDetails.Identifiers.
Identifiers []string `json:"identifiers"`
// Name is the device's name. Required.
Name string `json:"name"`
Model string `json:"model,omitempty"`
Manufacturer string `json:"manufacturer,omitempty"`
SwVersion string `json:"sw_version,omitempty"`
SerialNumber string `json:"serial_number,omitempty"`
HardwareVersion string `json:"hw_version,omitempty"`
// ConfigurationURL is a link to the device's own web UI.
ConfigurationURL string `json:"configuration_url,omitempty"`
// Connections are [type, id] pairs such as {"mac", "aa:bb:cc:00:11:22"} that
// link this device to others known by the same connection.
Connections [][2]string `json:"connections,omitempty"`
// SuggestedArea is the area Home Assistant proposes when the device is first discovered.
SuggestedArea string `json:"suggested_area,omitempty"`
// ViaDevice is the identifier of the device this one connects through (a hub or bridge).
ViaDevice string `json:"via_device,omitempty"`
}
type MQTTDiscoverySchema ¶
type MQTTDiscoverySchema interface {
IsMQTTDiscoverySchema()
}
type MediaPlayerMediaClass ¶
type MediaPlayerMediaClass string
MediaPlayerMediaClass is the class of a media item.
type SpeechToTextAudioBitRates ¶
type SpeechToTextAudioBitRates int
SpeechToTextAudioBitRates is a supported sample size in bits.
const ( SpeechToTextBitRate8 SpeechToTextAudioBitRates = 8 SpeechToTextBitRate16 SpeechToTextAudioBitRates = 16 SpeechToTextBitRate24 SpeechToTextAudioBitRates = 24 SpeechToTextBitRate32 SpeechToTextAudioBitRates = 32 )
The bit rates Home Assistant defines for speech to text.
type SpeechToTextAudioChannels ¶
type SpeechToTextAudioChannels int
SpeechToTextAudioChannels is a supported channel count.
const ( SpeechToTextChannelMono SpeechToTextAudioChannels = 1 SpeechToTextChannelStereo SpeechToTextAudioChannels = 2 )
The channel layouts Home Assistant defines for speech to text.
type SpeechToTextAudioCodecs ¶
type SpeechToTextAudioCodecs string
SpeechToTextAudioCodecs is a supported audio codec.
const ( SpeechToTextAudioCodecPCM SpeechToTextAudioCodecs = "pcm" SpeechToTextAudioCodecOpus SpeechToTextAudioCodecs = "opus" )
The audio codecs Home Assistant defines for speech to text.
type SpeechToTextAudioFormats ¶
type SpeechToTextAudioFormats string
SpeechToTextAudioFormats is a supported audio container format.
const SpeechToTextAudioFormatWAV SpeechToTextAudioFormats = "wav"
SpeechToTextAudioFormatWAV is the only container format Home Assistant defines.
type SpeechToTextAudioSampleRates ¶
type SpeechToTextAudioSampleRates int
SpeechToTextAudioSampleRates is a supported sample rate in Hz.
const ( SpeechToTextSampleRate8000 SpeechToTextAudioSampleRates = 8000 SpeechToTextSampleRate11025 SpeechToTextAudioSampleRates = 11025 SpeechToTextSampleRate16000 SpeechToTextAudioSampleRates = 16000 SpeechToTextSampleRate18900 SpeechToTextAudioSampleRates = 18900 SpeechToTextSampleRate22050 SpeechToTextAudioSampleRates = 22050 SpeechToTextSampleRate32000 SpeechToTextAudioSampleRates = 32000 SpeechToTextSampleRate37800 SpeechToTextAudioSampleRates = 37800 SpeechToTextSampleRate44100 SpeechToTextAudioSampleRates = 44100 SpeechToTextSampleRate48000 SpeechToTextAudioSampleRates = 48000 )
The sample rates Home Assistant defines for speech to text.
type TimeString ¶
type TimeString string
TimeString is a timestamp kept verbatim as returned by the API so that values round-trip byte for byte. Use Time to parse it.
type ToDoListTodoItemStatus ¶
type ToDoListTodoItemStatus string
ToDoListTodoItemStatus is the status of one to-do item.
const ( ToDoListTodoItemStatusNeedsAction ToDoListTodoItemStatus = "needs_action" ToDoListTodoItemStatusCompleted ToDoListTodoItemStatus = "completed" )
The statuses a to-do item can have.
type Unsubscribe ¶
Unsubscribe cancels an entity state subscription.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package api is Home Assistant's HTTP transport: the REST and WebSocket APIs.
|
Package api is Home Assistant's HTTP transport: the REST and WebSocket APIs. |
|
apitest
Package apitest is an httptest-based fake Home Assistant REST server for testing code that uses homeassistant-go/api.
|
Package apitest is an httptest-based fake Home Assistant REST server for testing code that uses homeassistant-go/api. |
|
cmd
|
|
|
demo
command
Command demo announces two sensors and a switch to a local broker and feeds them simulated values.
|
Command demo announces two sensors and a switch to a local broker and feeds them simulated values. |
|
generate
command
Command generate writes the domain packages (domains/...), icons/ and the MQTT discovery tables from the committed spec, the service catalog and the curation.
|
Command generate writes the domain packages (domains/...), icons/ and the MQTT discovery tables from the committed spec, the service catalog and the curation. |
|
mqtt-test
command
Command mqtt-test announces a sensor and a switch to a local broker and logs what Home Assistant sends back.
|
Command mqtt-test announces a sensor and a switch to a local broker and logs what Home Assistant sends back. |
|
domains
|
|
|
airquality
Package airquality is Home Assistant's air_quality domain: its types.
|
Package airquality is Home Assistant's air_quality domain: its types. |
|
aitask
Package aitask is Home Assistant's ai_task domain: its types.
|
Package aitask is Home Assistant's ai_task domain: its types. |
|
alarmcontrolpanel
Package alarmcontrolpanel is Home Assistant's alarm_control_panel domain: its types and its MQTT discovery config.
|
Package alarmcontrolpanel is Home Assistant's alarm_control_panel domain: its types and its MQTT discovery config. |
|
assistsatellite
Package assistsatellite is Home Assistant's assist_satellite domain: its types.
|
Package assistsatellite is Home Assistant's assist_satellite domain: its types. |
|
binarysensor
Package binarysensor is Home Assistant's binary_sensor domain: its types and its MQTT discovery config.
|
Package binarysensor is Home Assistant's binary_sensor domain: its types and its MQTT discovery config. |
|
button
Package button is Home Assistant's button domain: its types and its MQTT discovery config.
|
Package button is Home Assistant's button domain: its types and its MQTT discovery config. |
|
calendar
Package calendar is Home Assistant's calendar domain: its types.
|
Package calendar is Home Assistant's calendar domain: its types. |
|
camera
Package camera is Home Assistant's camera domain: its types and its MQTT discovery config.
|
Package camera is Home Assistant's camera domain: its types and its MQTT discovery config. |
|
climate
Package climate is Home Assistant's climate domain: its types and its MQTT discovery config.
|
Package climate is Home Assistant's climate domain: its types and its MQTT discovery config. |
|
conversation
Package conversation is Home Assistant's conversation domain: its types.
|
Package conversation is Home Assistant's conversation domain: its types. |
|
cover
Package cover is Home Assistant's cover domain: its types and its MQTT discovery config.
|
Package cover is Home Assistant's cover domain: its types and its MQTT discovery config. |
|
date
Package date is Home Assistant's date domain: its types and its MQTT discovery config.
|
Package date is Home Assistant's date domain: its types and its MQTT discovery config. |
|
datetime
Package datetime is Home Assistant's datetime domain: its types and its MQTT discovery config.
|
Package datetime is Home Assistant's datetime domain: its types and its MQTT discovery config. |
|
devicetracker
Package devicetracker is Home Assistant's device_tracker domain: its types and its MQTT discovery config.
|
Package devicetracker is Home Assistant's device_tracker domain: its types and its MQTT discovery config. |
|
devicetrigger
Package devicetrigger is Home Assistant's device_trigger domain: its types and its MQTT discovery config.
|
Package devicetrigger is Home Assistant's device_trigger domain: its types and its MQTT discovery config. |
|
event
Package event is Home Assistant's event domain: its types and its MQTT discovery config.
|
Package event is Home Assistant's event domain: its types and its MQTT discovery config. |
|
fan
Package fan is Home Assistant's fan domain: its types and its MQTT discovery config.
|
Package fan is Home Assistant's fan domain: its types and its MQTT discovery config. |
|
geolocation
Package geolocation is Home Assistant's geo_location domain: its types.
|
Package geolocation is Home Assistant's geo_location domain: its types. |
|
humidifier
Package humidifier is Home Assistant's humidifier domain: its types and its MQTT discovery config.
|
Package humidifier is Home Assistant's humidifier domain: its types and its MQTT discovery config. |
|
image
Package image is Home Assistant's image domain: its types and its MQTT discovery config.
|
Package image is Home Assistant's image domain: its types and its MQTT discovery config. |
|
imageprocessing
Package imageprocessing is Home Assistant's image_processing domain: its types.
|
Package imageprocessing is Home Assistant's image_processing domain: its types. |
|
infrared
Package infrared is Home Assistant's infrared domain: its types and its MQTT discovery config.
|
Package infrared is Home Assistant's infrared domain: its types and its MQTT discovery config. |
|
lawnmower
Package lawnmower is Home Assistant's lawn_mower domain: its types and its MQTT discovery config.
|
Package lawnmower is Home Assistant's lawn_mower domain: its types and its MQTT discovery config. |
|
light
Package light is Home Assistant's light domain: its types and its MQTT discovery config.
|
Package light is Home Assistant's light domain: its types and its MQTT discovery config. |
|
lock
Package lock is Home Assistant's lock domain: its types and its MQTT discovery config.
|
Package lock is Home Assistant's lock domain: its types and its MQTT discovery config. |
|
mediaplayer
Package mediaplayer is Home Assistant's media_player domain: its types.
|
Package mediaplayer is Home Assistant's media_player domain: its types. |
|
notify
Package notify is Home Assistant's notify domain: its types and its MQTT discovery config.
|
Package notify is Home Assistant's notify domain: its types and its MQTT discovery config. |
|
number
Package number is Home Assistant's number domain: its types and its MQTT discovery config.
|
Package number is Home Assistant's number domain: its types and its MQTT discovery config. |
|
radiofrequency
Package radiofrequency is Home Assistant's radio_frequency domain: its types.
|
Package radiofrequency is Home Assistant's radio_frequency domain: its types. |
|
remote
Package remote is Home Assistant's remote domain: its types.
|
Package remote is Home Assistant's remote domain: its types. |
|
scene
Package scene is Home Assistant's scene domain: its types and its MQTT discovery config.
|
Package scene is Home Assistant's scene domain: its types and its MQTT discovery config. |
|
selects
Package selects is Home Assistant's select domain: its types and its MQTT discovery config.
|
Package selects is Home Assistant's select domain: its types and its MQTT discovery config. |
|
sensor
Package sensor is Home Assistant's sensor domain: its types and its MQTT discovery config.
|
Package sensor is Home Assistant's sensor domain: its types and its MQTT discovery config. |
|
siren
Package siren is Home Assistant's siren domain: its types and its MQTT discovery config.
|
Package siren is Home Assistant's siren domain: its types and its MQTT discovery config. |
|
stt
Package stt is Home Assistant's stt domain: its types.
|
Package stt is Home Assistant's stt domain: its types. |
|
switches
Package switches is Home Assistant's switch domain: its types and its MQTT discovery config.
|
Package switches is Home Assistant's switch domain: its types and its MQTT discovery config. |
|
tag
Package tag is Home Assistant's tag domain: its types and its MQTT discovery config.
|
Package tag is Home Assistant's tag domain: its types and its MQTT discovery config. |
|
text
Package text is Home Assistant's text domain: its types and its MQTT discovery config.
|
Package text is Home Assistant's text domain: its types and its MQTT discovery config. |
|
time
Package time is Home Assistant's time domain: its types and its MQTT discovery config.
|
Package time is Home Assistant's time domain: its types and its MQTT discovery config. |
|
todo
Package todo is Home Assistant's todo domain: its types.
|
Package todo is Home Assistant's todo domain: its types. |
|
tts
Package tts is Home Assistant's tts domain: its types.
|
Package tts is Home Assistant's tts domain: its types. |
|
update
Package update is Home Assistant's update domain: its types and its MQTT discovery config.
|
Package update is Home Assistant's update domain: its types and its MQTT discovery config. |
|
vacuum
Package vacuum is Home Assistant's vacuum domain: its types and its MQTT discovery config.
|
Package vacuum is Home Assistant's vacuum domain: its types and its MQTT discovery config. |
|
valve
Package valve is Home Assistant's valve domain: its types and its MQTT discovery config.
|
Package valve is Home Assistant's valve domain: its types and its MQTT discovery config. |
|
wakeword
Package wakeword is Home Assistant's wake_word domain: its types.
|
Package wakeword is Home Assistant's wake_word domain: its types. |
|
waterheater
Package waterheater is Home Assistant's water_heater domain: its types and its MQTT discovery config.
|
Package waterheater is Home Assistant's water_heater domain: its types and its MQTT discovery config. |
|
weather
Package weather is Home Assistant's weather domain: its types.
|
Package weather is Home Assistant's weather domain: its types. |
|
Package entity is the transport-neutral runtime behind the domain packages (domains/light, domains/climate, ...).
|
Package entity is the transport-neutral runtime behind the domain packages (domains/light, domains/climate, ...). |
|
Package icons holds a constant for every Material Design Icon Home Assistant accepts as "mdi:<name>".
|
Package icons holds a constant for every Material Design Icon Home Assistant accepts as "mdi:<name>". |
|
internal
|
|
|
gen/curate
Package curate owns what Home Assistant core does not say.
|
Package curate owns what Home Assistant core does not say. |
|
gen/emit
Package emit prints the model as Go.
|
Package emit prints the model as Go. |
|
gen/model
Package model derives a typed model of each domain package from package spec (what Home Assistant core says), the service catalog and package curate (what core does not say).
|
Package model derives a typed model of each domain package from package spec (what Home Assistant core says), the service catalog and package curate (what core does not say). |
|
gen/spec
Package spec owns what upstream says: what internal/gen/extract reads out of Home Assistant core, committed as JSON under core/, and the service catalog dumped from a running Home Assistant.
|
Package spec owns what upstream says: what internal/gen/extract reads out of Home Assistant core, committed as JSON under core/, and the service catalog dumped from a running Home Assistant. |
|
test
Package test provides a shared integration test harness that runs a real Home Assistant instance together with a Mosquitto MQTT broker using docker compose.
|
Package test provides a shared integration test harness that runs a real Home Assistant instance together with a Mosquitto MQTT broker using docker compose. |
|
Package mqtt is the MQTT transport: the client, MQTT discovery and the core of a served Device.
|
Package mqtt is the MQTT transport: the client, MQTT discovery and the core of a served Device. |
|
internal/abbreviations
Package abbreviations holds the tables MQTT discovery payloads are read with, as Home Assistant core declares them (internal/gen/spec/core).
|
Package abbreviations holds the tables MQTT discovery payloads are read with, as Home Assistant core declares them (internal/gen/spec/core). |
|
mqtttest
Dual-protocol support cannot be proven by round-tripping homeassistant-go's client through itself: a v5 client and a v3.1.1 client agreeing with their own encoder proves nothing about what actually reached the wire.
|
Dual-protocol support cannot be proven by round-tripping homeassistant-go's client through itself: a v5 client and a v3.1.1 client agreeing with their own encoder proves nothing about what actually reached the wire. |