Documentation ¶
Index ¶
- Constants
- Variables
- type Agent
- type AgentService
- func (as *AgentService) Add(address string, label string) (*Agent, error)
- func (as *AgentService) GetAll() ([]Agent, error)
- func (as *AgentService) GetAmbient() (*Ambient, error)
- func (as *AgentService) InitPoll()
- func (as *AgentService) Poll(c context.Context, agent *Agent) error
- func (as *AgentService) PostSwitch(ctx context.Context, id, mac, command string) error
- func (as *AgentService) SendIR(ctx context.Context, id string, h []*hex.HexCode) error
- type Ambient
- type IRCode
- type Payload
- type Storage
- func (s *Storage) Add(address string, isDefault bool, label string) (*Agent, error)
- func (s *Storage) GetAll() ([]Agent, error)
- func (s *Storage) GetByAddress(address string) *Agent
- func (s *Storage) GetByID(id string) *Agent
- func (s *Storage) GetDefaultAgent() (Agent, error)
- func (s *Storage) Remove(id string) error
- func (s *Storage) Update(id string, entry *Agent) (*Agent, error)
- type SwitchBot
Constants ¶
View Source
const (
// PollingPeriod - Polling period seconds for fetch to agent
PollingPeriod = 5000
)
Variables ¶
View Source
var ErrAlreadyExists = &status.Error{ Error: errors.New("already exists"), Code: "ERR_AGENT_ALREADY_EXISTS", }
ErrAlreadyExists - When already exists
View Source
var ErrAmbientNotFetched = &status.Error{ Error: errors.New("ambient not fetched"), Code: "ERR_AMBIENT_NOT_FETCHED", }
ErrAmbientNotFetched - When ambient not fetched
View Source
var ErrDefaultAgentRequired = &status.Error{ Error: errors.New("default agent required"), Code: "ERR_DEFAULT_AGENT_REQUIRED", }
ErrDefaultAgentRequired - When try turn off last default agent
View Source
var ErrNoAgent = &status.Error{ Error: errors.New("no agents"), Code: "ERR_NO_AGENT", }
ErrNoAgent - When there is no agent
View Source
var ErrNotFound = &status.Error{ Error: errors.New("agent not found"), Code: "ERR_AGENT_NOT_FOUND", }
ErrNotFound - When agent does not exists
View Source
var ErrRemoveDefaultAgent = &status.Error{ Error: errors.New("can't delete default agent"), Code: "ERR_REMOVE_DEFAULT_AGENT", }
ErrRemoveDefaultAgent - When try remove default agent
Functions ¶
This section is empty.
Types ¶
type Agent ¶
type Agent struct { // ID - Agent ID ID string `json:"id" default:"<UNIQUE_ID>"` // Address - Agent Address (ex. `localhost:8081`) Address string `json:"address" validate:"required" example:"localhost:8081"` // Default - Agent to use by mainly Default bool `json:"default,omitempty"` // Label - Name of Agent (ex. `Bedroom`) Label string `json:"label,omitempty" example:"Bedroom"` // Online - Check online Online bool `json:"online,omitempty"` }
Agent - Store of Agent
type AgentService ¶ added in v0.0.27
AgentService - Provide Agent calls
func (*AgentService) Add ¶ added in v0.0.31
func (as *AgentService) Add(address string, label string) (*Agent, error)
Add - Add agent
func (*AgentService) GetAll ¶ added in v0.0.31
func (as *AgentService) GetAll() ([]Agent, error)
GetAll - Get all agents
func (*AgentService) GetAmbient ¶ added in v0.0.27
func (as *AgentService) GetAmbient() (*Ambient, error)
func (*AgentService) InitPoll ¶ added in v0.0.27
func (as *AgentService) InitPoll()
InitPoll - Start Poll task
func (*AgentService) Poll ¶ added in v0.0.27
func (as *AgentService) Poll(c context.Context, agent *Agent) error
Poll - Execute Poll
func (*AgentService) PostSwitch ¶ added in v0.0.27
func (as *AgentService) PostSwitch(ctx context.Context, id, mac, command string) error
type Ambient ¶
type Ambient struct { // Temp - Temperature (celsius) Temp float32 `json:"temp" example:"27.5"` // Humid - Humidity (percent) Humid float32 `json:"humid" example:"50.3"` // Pressure - Pressure (hpa) Pressure float32 `json:"pressure" example:"1009.4"` // LastFetch - Fetched date LastFetch time.Time `json:"last_fetch" example:"2020-01-01 01:02:03 UTC"` }
Ambient - Ambient sensor from BME280
type Storage ¶ added in v0.0.27
func NewStorage ¶ added in v0.0.27
func (*Storage) GetByAddress ¶ added in v0.0.31
GetByAddress - Return agent by Address
func (*Storage) GetDefaultAgent ¶ added in v0.0.31
GetDefaultAgent - Return default agent
Click to show internal directories.
Click to hide internal directories.