haws

package module
v0.4.3 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2023 License: MIT Imports: 10 Imported by: 1

Documentation

Index

Constants

View Source
const (
	EventStateChanged string = "state_changed"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type CallServiceTarget

type CallServiceTarget struct {
	DeviceID []string `json:"device_id,omitempty"`
	EntityID []string `json:"entity_id,omitempty"`
	AreaID   []string `json:"area_id,omitempty"`
}

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(url string, token string, reconnectHandler func(), reconnectTime time.Duration) *Client

func (*Client) AddEventHandler

func (c *Client) AddEventHandler(eventType string, handler EventHandler) error

func (*Client) CallService

func (c *Client) CallService(domain string, service string, serviceData map[string]interface{}, target *CallServiceTarget) error

func (*Client) Close

func (c *Client) Close() error

func (*Client) GetStates

func (c *Client) GetStates() ([]State, error)

func (*Client) Open

func (c *Client) Open() error

func (*Client) WaitAuth

func (c *Client) WaitAuth() error

type ErrPriorToAuth

type ErrPriorToAuth struct {
	// contains filtered or unexported fields
}

type EventData

type EventData struct {
	Data      json.RawMessage `json:"data"`
	EventType string          `json:"event_type"`
}

type EventHandler

type EventHandler interface {
	OnEvent(eventData *EventData)
}

type State

type State struct {
	State      string                 `json:"state"`
	EntityID   string                 `json:"entity_id"`
	Attributes map[string]interface{} `json:"attributes"`
}

type StateChangeEvent

type StateChangeEvent struct {
	EntityID string `json:"entity_id"`
	NewState *State `json:"new_state"`
	OldState *State `json:"old_state"`
}

type StateChangeEventHandler

type StateChangeEventHandler struct {
	// contains filtered or unexported fields
}

func NewStateChangeEventHandler

func NewStateChangeEventHandler(client *Client) (*StateChangeEventHandler, error)

func (*StateChangeEventHandler) AddHandler

func (c *StateChangeEventHandler) AddHandler(entityID string, handler StateChangeHandler)

func (*StateChangeEventHandler) OnEvent

func (c *StateChangeEventHandler) OnEvent(eventData *EventData)

func (*StateChangeEventHandler) SetDefaultHandler

func (c *StateChangeEventHandler) SetDefaultHandler(handler StateChangeHandler)

type StateChangeHandler

type StateChangeHandler interface {
	OnStateChange(event *StateChangeEvent)
}

Jump to

Keyboard shortcuts

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