-
Notifications
You must be signed in to change notification settings - Fork 2
/
device.go
executable file
·62 lines (51 loc) · 1.48 KB
/
device.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
56
57
58
59
60
61
62
package gbridge
import (
"github.com/pborges/gbridge/proto"
)
// Device represents a Smart Home Device with a Name, ID, and other metadata as defined by google [https://developers.google.com/assistant/smarthome/concepts/devices-traits]
type Device interface {
DeviceId() string
DeviceName() proto.DeviceName
DeviceType() proto.DeviceType
DeviceTraits() []Trait
}
// DeviceInfoProvider returns the metadata about a device.
type DeviceInfoProvider interface {
DeviceInfo() proto.DeviceInfo
}
type DeviceRoomHintProvider interface {
DeviceRoomHint() string
}
// BasicDevice represents a simple Smart Home Device
type BasicDevice struct {
Id string
Name proto.DeviceName
Type proto.DeviceType
Traits []Trait
Info proto.DeviceInfo
RoomHint string
}
// DeviceRoomHint returns in which Room this device should probally be.
func (d BasicDevice) DeviceRoomHint() string {
return d.RoomHint
}
// DeviceType returns which kind of device this is.
func (d BasicDevice) DeviceType() proto.DeviceType {
return d.Type
}
// DeviceInfo returns Information about the device
func (d BasicDevice) DeviceInfo() proto.DeviceInfo {
return d.Info
}
// DeviceId returns the Identifier of the device
func (d BasicDevice) DeviceId() string {
return d.Id
}
// DeviceName returns the Name
func (d BasicDevice) DeviceName() proto.DeviceName {
return d.Name
}
// DeviceTraits returns what functionality (trait) the device provides
func (d BasicDevice) DeviceTraits() []Trait {
return d.Traits
}