Documentation
¶
Index ¶
- type Access
- func (a *Access) CallService(domain, service, entityID string) error
- func (a *Access) ChangeState(id, state string) (s State, err error)
- func (a *Access) CheckAPI() error
- func (a *Access) FilterStates(domains ...string) (s States, err error)
- func (a *Access) FireEvent(eventType string, eventData interface{}) error
- func (a *Access) GetDevice(state State) (Device, error)
- func (a *Access) GetState(id string) (s State, err error)
- func (a *Access) IsSupportedDevice(id string) bool
- func (a *Access) ListStates() (s States, err error)
- func (a *Access) ListenEvents() (*EventListener, error)
- func (a *Access) ListenEventsWithContext(ctx context.Context) (*EventListener, error)
- func (a *Access) NewLight(id string) (light *Light)
- func (a *Access) NewLock(id string) (lock *Lock)
- func (a *Access) NewSwitch(id string) (s *Switch)
- func (a *Access) SetAccess(host, password string)
- func (a *Access) SetBearerToken(token string)
- func (a *Access) SetClient(client Doer)
- func (a *Access) SetToken(token string)
- func (a *Access) SupportedDeviceTypes() []string
- type Device
- type Doer
- type EventListener
- type Light
- type Lock
- type State
- type StateAttributes
- type StateChange
- type StateChangedEvent
- type States
- type Switch
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Access ¶
type Access struct {
// contains filtered or unexported fields
}
Access is the access and credentials for the API
func NewAccess ¶
NewAccess returns a new *Access to be used to interface with the Home Assistant system.
func (*Access) CallService ¶
CallService calls a service with a domain, service, and entity id.
func (*Access) ChangeState ¶
ChangeState changes the state of a device
func (*Access) CheckAPI ¶
CheckAPI checks whether or not the API is running. It returns an error if it is not running.
func (*Access) FilterStates ¶
FilterStates returns a list of states filtered by the list of domains
func (*Access) IsSupportedDevice ¶
IsSupportedDevice returns true if an entityID is a supported device
func (*Access) ListStates ¶
ListStates gets an array of state objects
func (*Access) ListenEvents ¶
func (a *Access) ListenEvents() (*EventListener, error)
func (*Access) ListenEventsWithContext ¶
func (a *Access) ListenEventsWithContext(ctx context.Context) (*EventListener, error)
func (*Access) SetBearerToken ¶
SetBearerToken sets the Authentiation: Bearer header Long Lived Access Tokens can be generated from the HASS UI
func (*Access) SupportedDeviceTypes ¶
SupportedDeviceTypes returns a list of supported device types
type EventListener ¶
type EventListener struct {
// contains filtered or unexported fields
}
func (*EventListener) Close ¶
func (e *EventListener) Close() error
Close closes the event listener library
func (*EventListener) NextStateChanged ¶
func (e *EventListener) NextStateChanged() (StateChangedEvent, error)
NextStateChanged waits and returns for the next state_changed event.
type Light ¶
type Light struct {
// contains filtered or unexported fields
}
Light describes a Light class
type Lock ¶
type Lock struct {
// contains filtered or unexported fields
}
Lock describes a Lock class
type State ¶
type State struct {
Attributes StateAttributes `json:"attributes"`
EntityID string `json:"entity_id"`
LastChanged time.Time `json:"last_changed"`
LastUpdated time.Time `json:"last_updated"`
State string `json:"state"`
}
State is the struct for an object state
type StateAttributes ¶
type StateAttributes map[string]interface{}
type StateChange ¶
StateChange is used for changing state on an entity
type StateChangedEvent ¶
type StateChangedEvent struct {
Origin string `json:"origin"`
EventType string `json:"event_type"`
TimeFired time.Time `json:"time_fired"`
Data struct {
OldState struct {
EntityID string `json:"entity_id"`
State string `json:"state"`
LastChanged time.Time `json:"last_changed"`
LastUpdated time.Time `json:"last_updated"`
Attributes StateAttributes `json:"attributes"`
} `json:"old_state"`
EntityID string `json:"entity_id"`
NewState struct {
EntityID string `json:"entity_id"`
State string `json:"state"`
LastChanged time.Time `json:"last_changed"`
LastUpdated time.Time `json:"last_updated"`
Attributes StateAttributes `json:"attributes"`
} `json:"new_state"`
} `json:"data"`
}