Documentation ¶
Index ¶
- Constants
- func AssertEqual(t *testing.T, a interface{}, b interface{})
- func AssertHc2SceneEqual(t *testing.T, got Hc2Scene, want Hc2Scene)
- func AssertHc2SceneWOLuaEqual(t *testing.T, got Hc2Scene, want Hc2Scene)
- func Default(fc *FibaroConfig)
- func FormatFullVersion(cmdName, version, branch, commit string) string
- type FibaroConfig
- type FibaroHc2
- func (f *FibaroHc2) Action(sceneID int, c SceneActionCommand) error
- func (f *FibaroHc2) AllScenes() []Hc2Scene
- func (f *FibaroHc2) Config() *FibaroConfig
- func (f *FibaroHc2) CreateScene(scene Hc2Scene) (newSceneID int)
- func (f *FibaroHc2) DebugMessages(sceneID int) []Hc2DebugMessage
- func (f *FibaroHc2) Info(indent int) string
- func (f *FibaroHc2) OneRoom(roomID int) Hc2Room
- func (f *FibaroHc2) OneScene(sceneID int) Hc2Scene
- func (f *FibaroHc2) OneSection(sectionID int) Hc2Section
- func (f *FibaroHc2) PutOneScene(scene Hc2Scene) (resp *resty.Response, err error)
- func (f *FibaroHc2) SetConfig(fc FibaroConfig)
- func (f *FibaroHc2) WriteInitConfigFile(path string) (bytesWrote int)
- type Hc2DebugMessage
- type Hc2Info
- type Hc2LoginStatus
- type Hc2Network
- type Hc2Room
- type Hc2Scene
- type Hc2Section
- type SceneActionCommand
Constants ¶
const ( // Hc2DefaultConfigFile is the default name of the configuration file Hc2DefaultConfigFile string = ".hc2-tools/config.json" // RepoName is the name of this repository RepoName string = "github.com/theovassiliou/hc2-tools" // Version contains the actuall version number. Might be replaces using the LDFLAGS. Version = "0.9.0-src" )
const ( TriggerAndManual string = "TRIGGER_AND_MANUAL" ManualOnly string = "MANUAL_ONLY" Disabled string = "DISABLED" )
Possible values to the used as runconfig field. Others are prohibited
Variables ¶
This section is empty.
Functions ¶
func AssertEqual ¶
AssertEqual checks if values are equal
func AssertHc2SceneEqual ¶
AssertHc2SceneEqual checks if two Hc2Scenes are equal, provided that the wanted Lua field contains a filename instead of a the actual lua script
func AssertHc2SceneWOLuaEqual ¶
AssertHc2SceneWOLuaEqual checks if two Hc2Scenes are equal, without looking into the lua field
func Default ¶
func Default(fc *FibaroConfig)
Default defines the default values for possible configuration file fields
func FormatFullVersion ¶
FormatFullVersion formats for a cmdName the version number based on version, branch and commit
Types ¶
type FibaroConfig ¶
type FibaroConfig struct { BaseURL string `json:"url"` Username string `json:"username"` Password string `json:"password"` CreateHeader bool `json:"createHeader"` }
FibaroConfig represents the configuration on how to access the Fibaro HC2 system
type FibaroHc2 ¶
type FibaroHc2 struct {
// contains filtered or unexported fields
}
FibaroHc2 represents the Fibaro HC2 system.
func NewFibaroHc2Config ¶
NewFibaroHc2Config creates a new FibaroHc2 object with the configuration read from a file. The information in the file is JSON encoded
func (*FibaroHc2) Action ¶
func (f *FibaroHc2) Action(sceneID int, c SceneActionCommand) error
Action starts an actions on a given sceneID
func (*FibaroHc2) AllScenes ¶
AllScenes downloads and returns all scenes of the FibaroHC2 system. nil will be returned in case an error occured while downloading the scenes.
func (*FibaroHc2) Config ¶
func (f *FibaroHc2) Config() *FibaroConfig
Config returns the configuration of the Fibaro system
func (*FibaroHc2) CreateScene ¶
CreateScene creates a new scene in the fibaro system with the name parameters set in the scene. SceneID will be updated with the new scene id being allocated. the header in the lua field will be updated. On sucess CreateScene will return the allocated SceneID, or -1 on error.
func (*FibaroHc2) DebugMessages ¶
func (f *FibaroHc2) DebugMessages(sceneID int) []Hc2DebugMessage
DebugMessages downloads and returns all debug messages for a given sceneID
func (*FibaroHc2) Info ¶
Info returns a human-readable string on information of the HC2 TODO: Write Tests
func (*FibaroHc2) OneSection ¶
func (f *FibaroHc2) OneSection(sectionID int) Hc2Section
OneSection downloads and returns a section as identified by the sectionID
func (*FibaroHc2) PutOneScene ¶
PutOneScene upploads a scene to the FibaroHc2 system and returns the response, or any error encountered.
func (*FibaroHc2) SetConfig ¶
func (f *FibaroHc2) SetConfig(fc FibaroConfig)
SetConfig sets the configuration of the FibaroHC2
func (*FibaroHc2) WriteInitConfigFile ¶
WriteInitConfigFile writes the configuration to a file. Paths required will be created if not presend.
type Hc2DebugMessage ¶
type Hc2DebugMessage struct { Timestamp int64 `json:"timestamp,omitempty"` Type string `json:"type,omitempty"` Txt string `json:"txt,omitempty"` }
Hc2DebugMessage represents a debug message of the FibaroHC2 system
type Hc2Info ¶
type Hc2Info struct { SerialNumber string `json:"serialNumber,omitempty"` HcName string `json:"hcName,omitempty"` Mac string `json:"mac,omitempty"` SoftVersion string `json:"softVersion,omitempty"` Beta bool `json:"beta,omitempty"` ZwaveVersion string `json:"zwaveVersion,omitempty"` ZwaveRegion string `json:"zwaveRegion,omitempty"` ServerStatus int `json:"serverStatus,omitempty"` }
Hc2Info represents the general information of the HC2 system. Can be encoded as JSON.
type Hc2LoginStatus ¶
type Hc2LoginStatus struct { Status bool `json:"status,omitempty"` UserID int `json:"userID,omitempty"` Username string `json:"username,omitempty"` Type string `json:"type,omitempty"` ErrorMsg string }
Hc2LoginStatus represents information on the logged user. Can be encoded as JSON.
type Hc2Network ¶
type Hc2Network struct { Dhcp bool `json:"dhcp"` IP string `json:"ip"` Mask string `json:"mask"` Gateway string `json:"gateway"` DNS string `json:"dns"` RemoteAccess bool `json:"remoteAccess"` RemoteAccessSupport int `json:"remoteAccessSupport"` }
Hc2Network represents the network information of the HC2 system. Can be encoded as JSON.
type Hc2Room ¶
type Hc2Room struct { RoomID int `json:"id"` Name string `json:"name"` SectionID int `json:"sectionID"` }
Hc2Room represents a room in the HC2 system. Can be encoded as JSON.
type Hc2Scene ¶
type Hc2Scene struct { SceneID int `json:"id,omitempty"` Name string `json:"name,omitempty"` RoomID int `json:"roomID,omitempty"` RunConfig string `json:"runConfig,omitempty"` MaxRunningInstances int `json:"maxRunningInstances,omitempty"` Lua string `json:"lua,omitempty"` Type string `json:"type,omitempty"` Autostart bool `json:"autostart,omitempty"` IsLua bool `json:"isLua,omitempty"` Visible bool `json:"visible,omitempty"` }
Hc2Scene represents a LUA scene of the FibaroHC2 system
func NewHc2Scene ¶
func NewHc2Scene() (scene Hc2Scene)
NewHc2Scene creates a new Hc2Scene object properly initialized
func (*Hc2Scene) Parse ¶
Parse parses a file input, and extracts the scene information located in comments. Comments are supposed to have the following format
--[[ FIBARO_GIT_HOOK @sceneID=203 @name="A_Trial_2" @roomID=305 @runConfig=TRIGGER_AND_MANUAL @maxRunningInstances=2 --]]
If there is no header included then SceneID will be set to -1, and lua will still contain the file content If there is a header and the appropriate tag is not included then the field will not be touched
func (*Hc2Scene) ParseFile ¶
ParseFile parses a file provided by it's path, and extracts the scene information located in comments, i.e. the FIBARO_GIT_HEADER. If trim set to true, existing FIBARO_GIT_HEADERs will be removed from the Lua field.
func (*Hc2Scene) SanityCheck ¶
SanityCheck performs checks on the value of some fields and returns false if a rule is beeing violated, true otherwise
func (*Hc2Scene) ToComment ¶
ToComment translates a Hc2Scene into a LUA comment and returns it as string.m
func (*Hc2Scene) TrimLuaHeaders ¶
func (scene *Hc2Scene) TrimLuaHeaders()
TrimLuaHeaders removes all FIBARO_GIT_HOOK headers from the Lua field and updates the field. If multiple headers are included all will be removed. No other fields of the Hc2Scene will be modified
func (*Hc2Scene) UpdateLuaHeader ¶
func (scene *Hc2Scene) UpdateLuaHeader()
UpdateLuaHeader deletes all headers and appends a new one add the end of the Lua scene with all field set to the Hc2Scene values.
type Hc2Section ¶
Hc2Section represents a section in the HC2 system. Can be encoded as JSON.
type SceneActionCommand ¶
type SceneActionCommand int
SceneActionCommand are the commands to be used in an action
const ( Undef SceneActionCommand = iota Start Stop Enable Disable )
Start, Stop, Enable, Disable are the commands to be used when triggering an action on a scene.
func (*SceneActionCommand) Set ¶
func (b *SceneActionCommand) Set(s string) error
Set the SceneActionCommand based on the string to be parsed. Returns error if not defined.
func (SceneActionCommand) String ¶
func (b SceneActionCommand) String() string