Documentation ¶
Index ¶
Constants ¶
const ( // ErrorCodeIDReuse is returned when id an already used ID ErrorCodeIDReuse = "id_reuse" // ErrorInvalidFormat is returned when the message is invalid or req id is 0 ErrorInvalidFormat = "invalid_format" )
Variables ¶
This section is empty.
Functions ¶
func InitSimpleClient ¶
func InitSimpleClient(scheme string, hassHost, hassToken string, healthCheckEntities []model.HassEntity)
InitSimpleClient inits the SimpleClient singleton
func InitWebSocketClient ¶
func InitWebSocketClient(scheme, hassHost, hassToken string)
InitWebSocketClient inits the WebSocketClient singleton
Types ¶
type ErrorStatusNotOK ¶
ErrorStatusNotOK is used to notify caller that a returned status is not considered OK
func NewErrorStatusNotOK ¶
func NewErrorStatusNotOK(status int) *ErrorStatusNotOK
func (ErrorStatusNotOK) Error ¶
func (e ErrorStatusNotOK) Error() string
type ResponseHandlerSignature ¶
type ResponseHandlerSignature func(model.HassAPIObject)
ResponseHandlerSignature is the callback func signature when receiving a response from the server
type SimpleClient ¶
type SimpleClient interface { GetEntities(domain string, name string) ([]model.HassEntity, error) GetEntity(domain string, name string) (model.HassEntity, error) CheckServerAPIHealth() error CallService(entity model.HassEntity, service string, extraParams map[string]interface{}) error }
SimpleClient is a client to make standard HTTP requests
func GetSimpleClient ¶
func GetSimpleClient() SimpleClient
GetSimpleClient returns the SimpleClient singleton
func NewSimpleClient ¶
func NewSimpleClient(hassConfig model.HassConfig) SimpleClient
NewSimpleClient returns a new SimpleClient object
type WebSocketClient ¶
type WebSocketClient interface { routines.Runnable RegisterCallback(hassType string, f ResponseHandlerSignature, concreteType model.HassAPIObject) SubscribeEvents(eventTypes ...string) }
WebSocketClient manages a WebSocket connection to hass
func GetWebSocketClient ¶
func GetWebSocketClient() WebSocketClient
GetWebSocketClient returns the WebSocketClient singleton
func NewWebSocketClient ¶
func NewWebSocketClient(config model.HassConfig) WebSocketClient
NewWebSocketClient returns a new NewWebSocketClient initialized
type WebSocketRequest ¶
type WebSocketRequest struct { Data model.HassAPIObject CreationTime time.Time LastUpdateTime time.Time }
WebSocketRequest is a request made from this client
func NewWebSocketRequest ¶
func NewWebSocketRequest(data model.HassAPIObject) *WebSocketRequest
NewWebSocketRequest creates a new WebSocketRequest
type WebSocketRequestsTracker ¶
type WebSocketRequestsTracker struct {
// contains filtered or unexported fields
}
WebSocketRequestsTracker tracks in progress WebSocketRequest objects
func (*WebSocketRequestsTracker) Done ¶
func (t *WebSocketRequestsTracker) Done(id uint64) *WebSocketRequest
Done deletes a previously stored WebSocketRequest and returns it
func (*WebSocketRequestsTracker) InProgress ¶
func (t *WebSocketRequestsTracker) InProgress(request *WebSocketRequest)
InProgress adds a WebSocketRequest to the "in progress" list
func (*WebSocketRequestsTracker) IsInProgress ¶
func (t *WebSocketRequestsTracker) IsInProgress(id uint64) bool
IsInProgress returns true if the request id is already in progress, false otherwise