mirror of
https://github.com/gosticks/go-hue-interface.git
synced 2025-10-16 11:45:35 +00:00
add function for getting bridge config
This commit is contained in:
parent
2bacde12f2
commit
4fbc421fc2
13
bridge.go
13
bridge.go
@ -13,6 +13,17 @@ type Bridge struct {
|
||||
Config *Config
|
||||
}
|
||||
|
||||
type BridgeUserConfig struct {
|
||||
Name string `json:"name"`
|
||||
APIVersion string `json:"apiversion"`
|
||||
IPAddress string `json:"ipaddress"`
|
||||
MAC string `json:"mac"`
|
||||
BridgeID string `json:"bridgeid"`
|
||||
DataStoreVersion string `json:"datastoreversion"`
|
||||
StarterKitID string `json:"starterkitid"`
|
||||
ReplacesBridgeID string `json:"replacesbridgeid"`
|
||||
}
|
||||
|
||||
// NewBridge creates a new bridge api instance
|
||||
func NewBridge(conf *Config) *Bridge {
|
||||
return &Bridge{
|
||||
@ -56,7 +67,7 @@ func (b *Bridge) getFromBridge(endpoint string, target interface{}) error {
|
||||
}
|
||||
|
||||
if res.StatusCode != http.StatusOK {
|
||||
return errors.New("Mite responded with error" + res.Status + fmt.Sprint(res.StatusCode))
|
||||
return errors.New("Hue responded with error" + res.Status + fmt.Sprint(res.StatusCode))
|
||||
}
|
||||
|
||||
// Unmarshal data
|
||||
|
||||
11
main.go
11
main.go
@ -10,10 +10,19 @@ func main() {
|
||||
fmt.Printf("go-hue-interface v. %s \n", VERSION)
|
||||
|
||||
config := &Config{
|
||||
Username: "nX1ye7AMQoQswiiJdxyw-92-RNhIwicXiQRg7AtF",
|
||||
Username: "nX1ye7AMQoQswiiJdxyw-92-RNhIwicXiQRg7AtF",
|
||||
BridgeAddr: "192.168.178.46",
|
||||
BridgeAddrScheme: "http",
|
||||
}
|
||||
|
||||
bridge := NewBridge(config)
|
||||
|
||||
fmt.Println("Created bridge ", bridge)
|
||||
|
||||
test := &BridgeUserConfig{}
|
||||
errCom := bridge.getFromBridge("/config", test)
|
||||
if errCom != nil {
|
||||
fmt.Println("[ERROR]" + errCom.Error())
|
||||
}
|
||||
fmt.Println(test)
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user