forked from evcc-io/evcc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
types.go
83 lines (68 loc) · 1.84 KB
/
types.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
package zaptec
import "strconv"
type ChargersResponse struct {
Pages int
Data []Charger
}
type Charger struct {
OperatingMode int
IsOnline bool
Id string
MID string
DeviceId string
SerialNo string
Name string
CreatedOnDate string
CircuitId string
Active bool
CurrentUserRoles int
DeviceType int
InstallationName string
InstallationId string
AuthenticationType int
IsAuthorizationRequired bool
}
type StateResponse []Observation
func (s *StateResponse) ObservationByID(id ObservationID) *Observation {
if s == nil {
return nil
}
for _, o := range *s {
if o.StateId == id {
return &o
}
}
return nil
}
type Observation struct {
ChargerId string
StateId ObservationID
Timestamp string
ValueAsString string
}
func (o *Observation) Bool() bool {
return o != nil && (o.ValueAsString == "true" || o.ValueAsString == "1")
}
func (o *Observation) Int() (int, error) {
if o == nil || o.ValueAsString == "" {
return 0, nil
}
return strconv.Atoi(o.ValueAsString)
}
func (o *Observation) Float64() (float64, error) {
if o == nil || o.ValueAsString == "" {
return 0, nil
}
return strconv.ParseFloat(o.ValueAsString, 64)
}
type Update struct {
MaxChargeCurrent *int `json:"maxChargeCurrent,omitempty"`
MaxChargePhases *int `json:"maxChargePhases,omitempty"`
MinChargeCurrent *int `json:"minChargeCurrent,omitempty"`
OfflineChargeCurrent *int `json:"offlineChargeCurrent,omitempty"`
OfflineChargePhase *int `json:"offlineChargePhase,omitempty"`
MeterValueInterval *int `json:"meterValueInterval,omitempty"`
}
type SessionPriority struct {
PrioritizedPhases *int `json:"prioritizedPhases,omitempty"`
}