-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvelux.go
47 lines (39 loc) · 1.04 KB
/
velux.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
package velux
// WindowType identifies a window device as a window or blind
type WindowType int
// WindowType enums
const (
WindowTypeWindow WindowType = iota
WindowTypeBlind
)
// WindowInfo capture identifying information and current position of a window.
type WindowInfo struct {
AccessoryID uint64
SerialNumber string
Type string
WindowType WindowType
CurrentPosition byte
TargetPosition byte
TargetPositionID uint64
Mapping *WindowMapping
}
// FriendlyName returns the mapped name if found. Serial number otherwise.
func (w *WindowInfo) FriendlyName() string {
if w.Mapping == nil || w.Mapping.Name == "" {
return w.SerialNumber
}
return w.Mapping.Name
}
// Code returns the mapped short code if found.
func (w *WindowInfo) Code() string {
if w.Mapping == nil || w.Mapping.Code == "" {
return w.Type
}
return w.Mapping.Code
}
// WindowMapping maps a window's SerialNumber to a friendly name and code
type WindowMapping struct {
SerialNumber string
Name string
Code string
}