forked from evcc-io/evcc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsite_api.go
71 lines (54 loc) · 1.34 KB
/
site_api.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
package core
import (
"errors"
"github.com/evcc-io/evcc/core/site"
)
var _ site.API = (*Site)(nil)
// GetPrioritySoC returns the PrioritySoC
func (site *Site) GetPrioritySoC() float64 {
site.Lock()
defer site.Unlock()
return site.PrioritySoC
}
// SetPrioritySoC sets the PrioritySoC
func (site *Site) SetPrioritySoC(soc float64) error {
site.Lock()
defer site.Unlock()
if len(site.batteryMeters) == 0 {
return errors.New("battery not configured")
}
site.PrioritySoC = soc
site.publish("prioritySoC", site.PrioritySoC)
return nil
}
// GetBufferSoC returns the BufferSoC
func (site *Site) GetBufferSoC() float64 {
site.Lock()
defer site.Unlock()
return site.BufferSoC
}
// SetBufferSoC sets the BufferSoC
func (site *Site) SetBufferSoC(soc float64) error {
site.Lock()
defer site.Unlock()
if len(site.batteryMeters) == 0 {
return errors.New("battery not configured")
}
site.BufferSoC = soc
site.publish("bufferSoC", site.BufferSoC)
return nil
}
// GetResidualPower returns the ResidualPower
func (site *Site) GetResidualPower() float64 {
site.Lock()
defer site.Unlock()
return site.ResidualPower
}
// SetResidualPower sets the ResidualPower
func (site *Site) SetResidualPower(power float64) error {
site.Lock()
defer site.Unlock()
site.ResidualPower = power
site.publish("residualPower", site.ResidualPower)
return nil
}