remote

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

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

Overview

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

Entity controls one remote entity over HTTP.

Home Assistant documents the domain here:

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

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

Control

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

Commands

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

MethodOver HTTP, calls
DeleteCommand remote.delete_command
LearnCommand remote.learn_command
SendCommand remote.send_command
Toggle remote.toggle
TurnOff remote.turn_off
TurnOn remote.turn_on

Control

type Entity struct

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

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

List returns every remote entity the transport can see.

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

DeleteCommand calls remote.delete_command. It has no MQTT equivalent. Core describes the service: Deletes a command or a list of commands from a remote's database.

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

LearnCommand calls remote.learn_command. It has no MQTT equivalent. Core describes the service: Teaches a remote a command or list of commands from a device.

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

SendCommand calls remote.send_command. It has no MQTT equivalent. Core describes the service: Sends a command or a list of commands to a device.

func (e *Entity) Toggle(ctx context.Context) error

Toggle calls remote.toggle. It has no MQTT equivalent. Core describes the service: Sends the toggle command.

func (e *Entity) TurnOff(ctx context.Context) error

TurnOff calls remote.turn_off. It has no MQTT equivalent. Core describes the service: Sends the turn off command.

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

TurnOn calls remote.turn_on. It has no MQTT equivalent. Core describes the service: Sends the turn on command.

type State = entity.State[Attributes]

State is a snapshot of one remote entity.

func Activity(value string) entity.ServiceOption

Activity sets the "activity" service data field.

func Alternative(value bool) entity.ServiceOption

Alternative sets the "alternative" service data field.

func Command(value any) entity.ServiceOption

Command sets the "command" service data field.

func CommandType(value string) entity.ServiceOption

CommandType sets the "command_type" service data field.

func DelaySecs(value float64) entity.ServiceOption

DelaySecs sets the "delay_secs" service data field.

func Device(value string) entity.ServiceOption

Device sets the "device" service data field.

func HoldSecs(value float64) entity.ServiceOption

HoldSecs sets the "hold_secs" service data field.

func NumRepeats(value float64) entity.ServiceOption

NumRepeats sets the "num_repeats" service data field.

func Timeout(value float64) entity.ServiceOption

Timeout sets the "timeout" service data field.

State and values

type Attributes struct

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

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

FieldTypeWire keyDescription
ActivityList*[]stringactivity_list
CurrentActivity*stringcurrent_activity
SupportedFeaturesFeaturesupported_features

A set of Feature flags.

Feature

type Feature uint64

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

ConstantValue
FeatureUnknown0
FeatureLearnCommand1 << 0
FeatureDeleteCommand1 << 1
FeatureActivity1 << 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.