tts

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

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

Overview

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

Entity controls one tts entity over HTTP.

No method for tts.clear_cache, tts.cloud_say and tts.demo_say, which target no entity: call api.Client.CallService.

Home Assistant documents the domain here:

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

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

Control

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

Commands

What each Entity method does on each transport. Home Assistant has no MQTT discovery for this domain.

MethodOver HTTP, calls
Speak tts.speak

Services without a method

Call these with the REST or WebSocket client.

ServiceWhy
tts.clear_cacheit targets no entity
tts.cloud_sayit targets no entity
tts.demo_sayit targets no entity

Control

type Entity struct

Entity controls one tts 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 tts entity with the given id: an entity id over HTTP (the "tts." prefix may be omitted). It does no I/O.

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

List returns every tts entity the transport can see.

func (e *Entity) Speak(ctx context.Context, options ...entity.ServiceOption) error

Speak calls tts.speak. It has no MQTT equivalent. Core describes the service: Speaks something using text-to-speech on a media player.

type State = entity.State[Attributes]

State is a snapshot of one tts entity.

func Cache(value bool) entity.ServiceOption

Cache sets the "cache" service data field.

func Language(value string) entity.ServiceOption

Language sets the "language" service data field.

func MediaPlayerEntityId(value string) entity.ServiceOption

MediaPlayerEntityId sets the "media_player_entity_id" service data field.

func Message(value string) entity.ServiceOption

Message sets the "message" service data field.

func Options(value map[string]any) entity.ServiceOption

Options sets the "options" service data field.

State and values

type Attributes struct

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

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

type Voice struct

Voice is core's Voice.

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

FieldTypeWire keyDescription
Namestringname
VoiceIdstringvoice_id