-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathappliance.go
55 lines (50 loc) · 1.76 KB
/
appliance.go
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
54
55
package natureremo
// Appliance represents controlable devices with Nature Remo
// such as air conditioners and TVs.
type Appliance struct {
ID string `json:"id"`
Type ApplianceType `json:"type"`
Device *DeviceCore `json:"device"`
Model *ApplianceModel `json:"model"`
Nickname string `json:"nickname"`
Image string `json:"image"`
Signals []*Signal `json:"signals"`
AirConSettings *AirConSettings `json:"settings"`
AirCon *AirCon `json:"aircon"`
TV *TV `json:"tv"`
Light *Light `json:"light"`
}
// SignalByName gets a signal by name from Signals.
// If there are not any signals which have specified name,
// SignalByName returns nil.
func (a *Appliance) SignalByName(name string) *Signal {
for _, s := range a.Signals {
if s.Name == name {
return s
}
}
return nil
}
// ApplianceType represents type of appliance.
type ApplianceType string
const (
// ApplianceTypeAirCon represents an air conditioner.
ApplianceTypeAirCon ApplianceType = "AC"
// ApplianceTypeTV represents an TV
ApplianceTypeTV ApplianceType = "TV"
// ApplianceTypeLight represents Light
ApplianceTypeLight ApplianceType = "LIGHT"
// ApplianceTypeIR represents a device which is controlled by infrared.
ApplianceTypeIR ApplianceType = "IR"
)
// ApplianceModel is device information of appliance
// which is identified by Nature Remo API.
type ApplianceModel struct {
ID string `json:"id"`
// Not in swagger, but actually included in the response
Country string `json:"country"`
Manufacturer string `json:"manufacturer"`
RemoteName string `json:"remote_name"`
Name string `json:"name"`
Image string `json:"image"`
}