gohaws

package module
v0.0.0-...-a52c82b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 21, 2023 License: MIT Imports: 7 Imported by: 1

README

gohaws

A Golang Home Assistant Web Socket client

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Data

type Data struct {
	EntityID  string                 `json:"entity_id,omitempty"`
	EventType string                 `json:"data,omitempty"`
	TimeFired time.Time              `json:"time_fired,omitempty"`
	Origin    string                 `json:"origin,omitempty"`
	Context   *HaContext             `json:"context,omitempty"`
	NewState  *State                 `json:"new_state,omitempty"`
	OldState  map[string]interface{} `json:"old_state,omitempty"`
}

type Event

type Event struct {
	Data *Data `json:"data,omitempty"`
}

type HaClient

type HaClient struct {
	URI          string
	Token        string
	Conn         *websocket.Conn
	AuthChannel  chan *Message
	OtherChannel chan *Message
	EventChannel chan *Message
	ID           int64
	// contains filtered or unexported fields
}

func New

func New(ctx context.Context, URI, token string) *HaClient

func (*HaClient) Add

func (ha *HaClient) Add(entityName string)

func (*HaClient) CallService

func (ha *HaClient) CallService(ctx context.Context, domain string, service string, serviceData interface{}, target string) error

func (*HaClient) SubscribeToUpdates

func (ha *HaClient) SubscribeToUpdates(ctx context.Context) error

type HaContext

type HaContext struct {
	ID       string `json:"id,omitempty"`
	ParentID string `json:"parent_id,omitempty"`
	UserID   string `json:"user_id,omitempty"`
}

type Message

type Message struct {
	ID          int64             `json:"id,omitempty"`
	AccessToken string            `json:"access_token,omitempty"`
	Type        string            `json:"type,omitempty"`
	Event       *Event            `json:"event,omitempty"`
	EventType   string            `json:"event_type,omitempty"`
	Domain      string            `json:"domain,omitempty"`
	Service     string            `json:"service,omitempty"`
	ServiceData interface{}       `json:"service_data,omitempty"`
	Target      map[string]string `json:"target,omitempty"`
	Success     bool              `json:"success,omitempty"`
	Result      *HaContext        `json:"result,omitempty"`
}

type State

type State struct {
	DeviceClass       string      `json:"device_class,omitempty"`
	FriendlyName      string      `json:"friendly_name,omitempty"`
	Icon              string      `json:"icon,omitempty"`
	StateClass        string      `json:"state_class,omitempty"`
	UnitOfMeasurement string      `json:"unit_of_measurement,omitempty"`
	Context           *HaContext  `json:"context,omitempty"`
	EntityID          string      `json:"entity_id,omitempty"`
	LastChanged       time.Time   `json:"last_changed,omitempty"`
	LastUpdated       time.Time   `json:"last_updated,omitempty"`
	State             interface{} `json:"state,omitempty"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL