Documentation ¶
Index ¶
- Variables
- type Controller
- type Entry
- type EntrySet
- type Options
- type PushResult
- type Storage
- func (s *Storage) Create(name string, kind appliances.Kind, t string, opts *Options) (*Entry, error)
- func (s *Storage) GetAll() map[string]*Entry
- func (s *Storage) GetByID(id string) (*Entry, error)
- func (s *Storage) GetByName(name string) (*Entry, error)
- func (s *Storage) Load() error
- func (s *Storage) Remove(id string) error
- func (s *Storage) Save() error
- func (s *Storage) Update(id, name string, kind appliances.Kind, t string, opts *Options) (*Entry, error)
- type SwitchBotEntry
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrAlreadyExists = &status.Error{ Error: errors.New("already exists"), Code: "ERR_CONTROLLER_ALREADY_EXISTS", }
ErrAlreadyExists - When already exists
View Source
var ErrInvalidType = &status.Error{ Error: errors.New("invalid type provided"), Code: "ERR_INVALID_TYPE", }
ErrInvalidType - When provided invalid type
View Source
var ErrNameTooLong = &status.Error{ Error: errors.New("name too long"), Code: "ERR_NAME_TOO_LONG", }
ErrNameTooLong - When name than 20 characters
View Source
var ErrNotFound = &status.Error{ Error: errors.New("controller not found"), Code: "ERR_CONTROLLER_NOT_FOUND", }
ErrNotFound - When controller does not exists
View Source
var ErrUnsupportedKind = &status.Error{ Error: errors.New("unsupported kind"), Code: "ERR_UNSUPPORTED_KIND", }
ErrUnsupportedKind - When provided unsupported Kind
View Source
var ErrUnsupportedType = &status.Error{ Error: errors.New("unsupported type"), Code: "ERR_UNSUPPORTED_TYPE", }
ErrUnsupportedType - When provided unsupported Type
View Source
var ErrValidateMacAddress = &status.Error{ Error: errors.New("invalid mac address"), Code: "ERR_INVALID_MAC_ADDRESS", }
ErrValidateMacAddress - When error occurred while in validate mac address...
Functions ¶
This section is empty.
Types ¶
type Controller ¶
type Controller struct { Storage *Storage Agent *agent.AgentService Remotes *remotego.Remote }
func New ¶
func New(basePath string, agent *agent.AgentService) (*Controller, error)
func (*Controller) Push ¶ added in v0.0.41
func (c *Controller) Push(id string, es *EntrySet) (*PushResult, error)
func (*Controller) RaiseSwitchBot ¶
func (c *Controller) RaiseSwitchBot(id string, command string) error
type Entry ¶
type Entry struct { // ID - Generated ID ID string `json:"id,omitempty" example:"<UNIQUE_ID>"` // AgentID - Use for another agent AgentID string `json:"agent_id,omitempty" example:"<AGENT_ID>"` // Name - ex. Bedroom Airconditioner Name string `json:"name" validate:"required" example:"Bedroom Airconditioner"` // Kind - AIRCON, LIGHT, SWITCHBOT... Kind appliances.Kind `json:"kind" validate:"required" example:"AIRCON"` // Type - type of controller (how to use?) / ex. REMOTE, SWITCHBOT... Type string `json:"type" validate:"required" example:"REMOTE"` // Remote - Remote Controller settings (required when type is REMOTE) Remote *remote.Remote `json:"remote,omitempty"` // SwitchBot - SwitchBot settings (required when type is SWITCHBOT) SwitchBot *agent.SwitchBot `json:"switchbot,omitempty"` // Appliances - State of appliances Appliances *appliances.State `json:"appliances,omitempty"` }
type EntrySet ¶ added in v0.0.41
type EntrySet struct { Remote appliances.Request `json:"remote,omitempty"` SwitchBot *SwitchBotEntry `json:"switchbot,omitempty"` }
EntrySet - Combined remote-go entry (aircon, light etc.)
type PushResult ¶ added in v0.0.41
type PushResult struct { // Aircon - use entry (return current mode) Aircon *appliances.Aircon `json:"aircon,omitempty"` // Light - use state (return all values) Light *appliances.LightState `json:"light,omitempty"` // SwitchBot - use entry (return requested command) SwitchBot *SwitchBotEntry `json:"switchbot,omitempty"` }
PushResult - result of push
type Storage ¶
type Storage struct { Path string Entries map[string]*Entry Remotes *remotego.Remote AgentStore *agent.Storage }
func NewStorage ¶
func (*Storage) Create ¶
func (s *Storage) Create(name string, kind appliances.Kind, t string, opts *Options) (*Entry, error)
Create - Create new Controller
type SwitchBotEntry ¶ added in v0.0.41
type SwitchBotEntry struct {
Command string `json:"command,omitempty"`
}
SwitchBotEntry - request entry of switchbot
Click to show internal directories.
Click to hide internal directories.