mirror of
https://github.com/gosticks/go-hue-interface.git
synced 2025-10-16 11:45:35 +00:00
add hue state
This commit is contained in:
parent
17546acf17
commit
fdcd78eb85
4
main.go
4
main.go
@ -19,8 +19,8 @@ func main() {
|
||||
|
||||
fmt.Println("Created bridge ", bridge)
|
||||
|
||||
test := &BridgeUserConfig{}
|
||||
errCom := bridge.getFromBridge("/config", test)
|
||||
test := &BridgeState{}
|
||||
errCom := bridge.getFromBridge("", test)
|
||||
if errCom != nil {
|
||||
fmt.Println("[ERROR]" + errCom.Error())
|
||||
}
|
||||
|
||||
44
state.go
Normal file
44
state.go
Normal file
@ -0,0 +1,44 @@
|
||||
package main
|
||||
|
||||
import "fmt"
|
||||
|
||||
// -------------------------------------------------------------
|
||||
// ~ Interfaces & Types
|
||||
// -------------------------------------------------------------
|
||||
|
||||
type BridgeState struct {
|
||||
Lights map[string]*Light `json:"lights"`
|
||||
}
|
||||
|
||||
type Light struct {
|
||||
State *LightState `json:"state"`
|
||||
Type string `json:"type"`
|
||||
Name string `json:"name"`
|
||||
ModelID string `json:"modelid"`
|
||||
SwVersion string `json:"swversion"`
|
||||
}
|
||||
|
||||
type LightState struct {
|
||||
On bool `json:"on"`
|
||||
BridgeID int `json:"bridgeid"`
|
||||
Hue int `json:"hue"`
|
||||
XY []int `json:"xy"`
|
||||
Ct int `json:"ct"`
|
||||
Alert string `json:"alert"`
|
||||
Effect string `json:"effect"`
|
||||
ColorMode string `json:"colormode"`
|
||||
Reachable bool `json:"reachable"`
|
||||
}
|
||||
|
||||
func (l *Light) String() string {
|
||||
return fmt.Sprintf("Name=\"%s\" Model=\"%s\" On=\"%x\" \n", l.Name, l.ModelID, l.State.On)
|
||||
}
|
||||
|
||||
func (bs *BridgeState) String() string {
|
||||
str := ""
|
||||
for k, l := range bs.Lights {
|
||||
str += k + ": " + l.String()
|
||||
}
|
||||
|
||||
return str
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user