aboutsummaryrefslogtreecommitdiff
path: root/group.go
blob: 4a3634608eb1bcf98cb0095ee7b5333128f35e7c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/*
* group.go
* GoHue library for Philips Hue
* Copyright (C) 2016 Collin Guarino (Collinux) collin.guarino@gmail.com
* License: GPL version 2 or higher http://www.gnu.org/licenses/gpl.html
 */
// http://www.developers.meethue.com/documentation/groups-api

package hue

import (
	"encoding/json"
	"fmt"
)

// Group struct defines the attributes for a group of lights.
type Group struct {
	Action struct {
		Alert     string    `json:"alert"`
		Bri       int       `json:"bri"`
		Colormode string    `json:"colormode"`
		Ct        int       `json:"ct"`
		Effect    string    `json:"effect"`
		Hue       int       `json:"hue"`
		On        bool      `json:"on"`
		Sat       int       `json:"sat"`
		XY        []float64 `json:"xy"`
	} `json:"action"`
	Lights []string `json:"lights"`
	Name   string   `json:"name"`
	Type   string   `json:"type"`
}

// Bridge.GetGroups gets the attributes for each group of lights.
// TODO: NOT TESTED, NOT FULLY IMPLEMENTED
func (bridge *Bridge) GetGroups() ([]Group, error) {
	uri := fmt.Sprintf("/api/%s/groups", bridge.Username)
	body, _, err := bridge.Get(uri)
	if err != nil {
		return []Group{}, err
	}

	//fmt.Println("GROUP GET: ", string(body))

	groups := map[string]Group{}
	err = json.Unmarshal(body, &groups)
	if err != nil {
		return []Group{}, err
	}
	//fmt.Println("GROUPS: ", groups)

	return []Group{}, nil
}