forked from evcc-io/evcc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
embed.go
70 lines (57 loc) · 1.65 KB
/
embed.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
package vehicle
import (
"github.com/evcc-io/evcc/api"
)
// TODO align phases with OnIdentify
type embed struct {
Title_ string `mapstructure:"title"`
Icon_ string `mapstructure:"icon"`
Capacity_ float64 `mapstructure:"capacity"`
Phases_ int `mapstructure:"phases"`
Identifiers_ []string `mapstructure:"identifiers"`
Features_ []api.Feature `mapstructure:"features"`
OnIdentify api.ActionConfig `mapstructure:"onIdentify"`
}
// Title implements the api.Vehicle interface
func (v *embed) fromVehicle(title string, capacity float64) {
if v.Title_ == "" {
v.Title_ = title
}
if v.Capacity_ == 0 {
v.Capacity_ = capacity
}
}
// Title implements the api.Vehicle interface
func (v *embed) Title() string {
return v.Title_
}
// SetTitle implements the api.TitleSetter interface
func (v *embed) SetTitle(title string) {
v.Title_ = title
}
// Capacity implements the api.Vehicle interface
func (v *embed) Capacity() float64 {
return v.Capacity_
}
// Phases returns the phases used by the vehicle
func (v *embed) Phases() int {
return v.Phases_
}
// Identifiers implements the api.Identifier interface
func (v *embed) Identifiers() []string {
return v.Identifiers_
}
// OnIdentified returns the identify action
func (v *embed) OnIdentified() api.ActionConfig {
return v.OnIdentify
}
var _ api.IconDescriber = (*embed)(nil)
// Icon implements the api.IconDescriber interface
func (v *embed) Icon() string {
return v.Icon_
}
var _ api.FeatureDescriber = (*embed)(nil)
// Features implements the api.FeatureDescriber interface
func (v *embed) Features() []api.Feature {
return v.Features_
}