-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodels_overlay.go
112 lines (92 loc) · 3.15 KB
/
models_overlay.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
package tado
import (
"fmt"
"net/http"
"time"
)
// TerminationType is an enum type for overlay termination types
type TerminationType string
const (
//TerminationTypeManual is used for manual termination
TerminationTypeManual TerminationType = "MANUAL"
// TerminationTypeTimer is used for automation termination, use property DurationInSeconds to set the timer duration
TerminationTypeTimer TerminationType = "TIMER"
// TerminationTypeTadoMode is used to terminate this setting by Tado, the overlay ends when the schema changes
TerminationTypeTadoMode TerminationType = "TADO_MODE"
)
// OverlayInput is the main input for an overlay
type OverlayInput struct {
Setting OverlayInputSetting `json:"setting"`
Termination OverlayInputTermination `json:"termination"`
}
// OverlayInputSetting contains the settings for the overlay
type OverlayInputSetting struct {
Type string `json:"type"`
Power string `json:"power"`
Temperature OverlayInputTemperature `json:"temperature"`
}
// OverlayInputTermination contains the termination settings for the overlay
type OverlayInputTermination struct {
Type TerminationType `json:"type"`
DurationInSeconds int `json:"durationInSeconds,omitempty"`
}
// OverlayInputTemperature contains the temperature settings for the overlay
type OverlayInputTemperature struct {
Celsius float64 `json:"celsius,omitempty"`
Fahrenheit float64 `json:"fahrenheit,omitempty"`
}
// OverlayOutput is the output for a successful overlay update
type OverlayOutput struct {
Type string `json:"type"`
Setting struct {
Type string `json:"type"`
Power string `json:"power"`
Temperature struct {
Celsius float64 `json:"celsius"`
Fahrenheit float64 `json:"fahrenheit"`
} `json:"temperature"`
} `json:"setting"`
Termination struct {
Type string `json:"type"`
TypeSkillBasedApp string `json:"typeSkillBasedApp"`
DurationInSeconds int `json:"durationInSeconds"`
Expiry time.Time `json:"expiry"`
RemainingTimeInSeconds int `json:"remainingTimeInSeconds"`
ProjectedExpiry time.Time `json:"projectedExpiry"`
} `json:"termination"`
}
// PutOverlayInput is the input for PutOverlay
type PutOverlayInput struct {
HomeID int
ZoneID int
OverlayInput
}
func (poi *PutOverlayInput) method() string {
return http.MethodPut
}
func (poi *PutOverlayInput) path() string {
return fmt.Sprintf("/v2/homes/%d/zones/%d/overlay", poi.HomeID, poi.ZoneID)
}
func (poi *PutOverlayInput) body() interface{} {
return poi.OverlayInput
}
// PutOverlayOutput is the output for PutOverlay
type PutOverlayOutput struct {
OverlayOutput
}
// DeleteOverlayInput is the input for DeleteOverlay
type DeleteOverlayInput struct {
HomeID int
ZoneID int
}
func (poi *DeleteOverlayInput) method() string {
return http.MethodDelete
}
func (poi *DeleteOverlayInput) path() string {
return fmt.Sprintf("/v2/homes/%d/zones/%d/overlay", poi.HomeID, poi.ZoneID)
}
func (poi *DeleteOverlayInput) body() interface{} {
return nil
}
// DeleteOverlayOutput is the output for DeleteOverlay
type DeleteOverlayOutput struct{}