Overview
Package aitask is Home Assistant's ai_task domain: its types.
Entity controls one ai_task entity over HTTP.
No method for ai_task.evaluate, ai_task.generate_data and ai_task.generate_image, which only answer with data: call api.Client.CallServiceForResponse.
No method for ai_task.clear_images, which target no entity: call api.Client.CallService.
Home Assistant documents the domain here:
Integration: https://www.home-assistant.io/integrations/ai_task/
Entity model (developers): https://contributors.home-assistant.io/core/entities/ai-task/
Control
// client is an *api.Client
target := aitask.Get(client, "my_ai_task")
state, err := target.State(ctx)
Commands
Services without a method
Call these with the REST or WebSocket client.
| Service | Why |
|---|---|
ai_task.clear_images | it targets no entity |
ai_task.evaluate | it only answers with data |
ai_task.generate_data | it only answers with data |
ai_task.generate_image | it only answers with data |
Control
type Entity struct
Entity controls one ai_task 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 ai_task entity with the given id: an entity id over HTTP (the "ai_task." prefix may be omitted). It does no I/O.
func List(ctx context.Context, transport entity.Transport) ([]*Entity, error)
List returns every ai_task entity the transport can see.
type State = entity.State[Attributes]
State is a snapshot of one ai_task entity.
State and values
type Attributes struct
Attributes are the state attributes of a ai_task entity, under the names Home Assistant publishes them with.
See: https://www.home-assistant.io/integrations/ai_task/
| Field | Type | Wire key | Description |
|---|---|---|---|
SupportedFeatures | Feature | supported_features | A set of Feature flags. |
type ChoiceAnswer struct
ChoiceAnswer is core's ChoiceAnswer.
See: https://www.home-assistant.io/integrations/ai_task/
| Field | Type | Wire key | Description |
|---|---|---|---|
Choice | string | choice | |
Probabilities | map[string]float64 | probabilities | |
Type | string | type |
type EvaluationTaskResult struct
EvaluationTaskResult is core's EvaluationTaskResult.
See: https://www.home-assistant.io/integrations/ai_task/
| Field | Type | Wire key | Description |
|---|---|---|---|
Answers | map[string]any | answers |
Feature
type Feature uint64
Feature is a set of ai_task supported features, with the values of core's AITaskEntityFeature: the supported_features attribute decodes into it.
| Constant | Value |
|---|---|
FeatureUnknown | 0 |
FeatureGenerateData | 1 << 0 |
FeatureSupportAttachments | 1 << 1 |
FeatureGenerateImage | 1 << 2 |
FeatureEvaluate | 1 << 3 |
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 GenDataTaskResult struct
GenDataTaskResult is core's GenDataTaskResult.
See: https://www.home-assistant.io/integrations/ai_task/
| Field | Type | Wire key | Description |
|---|---|---|---|
ConversationId | string | conversation_id | |
Data | any | data |
type NoulAnswer struct
NoulAnswer is core's NoulAnswer.
See: https://www.home-assistant.io/integrations/ai_task/
| Field | Type | Wire key | Description |
|---|---|---|---|
Noul | float64 | noul | |
Type | string | type |
type ScoreAnswer struct
ScoreAnswer is core's ScoreAnswer.
See: https://www.home-assistant.io/integrations/ai_task/
| Field | Type | Wire key | Description |
|---|---|---|---|
Probabilities | []float64 | probabilities | |
Score | float64 | score | |
Type | string | type |