HEMS: indicate §14a circuit limit (#23927)
This commit is contained in:
parent
3c2f0dfad6
commit
0e3a9dcd80
6 changed files with 56 additions and 0 deletions
|
|
@ -258,6 +258,10 @@ type Circuit interface {
|
|||
Update([]CircuitLoad) error
|
||||
ValidateCurrent(old, new float64) float64
|
||||
ValidatePower(old, new float64) float64
|
||||
|
||||
// §14a
|
||||
Dim(bool)
|
||||
Dimmed() bool
|
||||
}
|
||||
|
||||
// Redactor is an interface to redact sensitive data
|
||||
|
|
|
|||
26
api/mock.go
26
api/mock.go
|
|
@ -816,6 +816,32 @@ func (m *MockCircuit) EXPECT() *MockCircuitMockRecorder {
|
|||
return m.recorder
|
||||
}
|
||||
|
||||
// Dim mocks base method.
|
||||
func (m *MockCircuit) Dim(arg0 bool) {
|
||||
m.ctrl.T.Helper()
|
||||
m.ctrl.Call(m, "Dim", arg0)
|
||||
}
|
||||
|
||||
// Dim indicates an expected call of Dim.
|
||||
func (mr *MockCircuitMockRecorder) Dim(arg0 any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Dim", reflect.TypeOf((*MockCircuit)(nil).Dim), arg0)
|
||||
}
|
||||
|
||||
// Dimmed mocks base method.
|
||||
func (m *MockCircuit) Dimmed() bool {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "Dimmed")
|
||||
ret0, _ := ret[0].(bool)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// Dimmed indicates an expected call of Dimmed.
|
||||
func (mr *MockCircuitMockRecorder) Dimmed() *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Dimmed", reflect.TypeOf((*MockCircuit)(nil).Dimmed))
|
||||
}
|
||||
|
||||
// GetChargePower mocks base method.
|
||||
func (m *MockCircuit) GetChargePower() float64 {
|
||||
m.ctrl.T.Helper()
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ type Circuit struct {
|
|||
|
||||
current float64
|
||||
power float64
|
||||
dimmed bool
|
||||
|
||||
currentUpdated time.Time
|
||||
powerUpdated time.Time
|
||||
|
|
@ -374,3 +375,24 @@ func (c *Circuit) ValidateCurrent(old, new float64) float64 {
|
|||
|
||||
return c.parent.ValidateCurrent(old, new)
|
||||
}
|
||||
|
||||
func (c *Circuit) Dim(dim bool) {
|
||||
c.mu.Lock()
|
||||
defer c.mu.Unlock()
|
||||
c.dimmed = dim
|
||||
}
|
||||
|
||||
func (c *Circuit) Dimmed() bool {
|
||||
c.mu.RLock()
|
||||
defer c.mu.RUnlock()
|
||||
|
||||
if c.dimmed {
|
||||
return true
|
||||
}
|
||||
|
||||
if c.parent == nil {
|
||||
return false
|
||||
}
|
||||
|
||||
return c.parent.Dimmed()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ type circuitStruct struct {
|
|||
Current *float64 `json:"current,omitempty"`
|
||||
MaxPower float64 `json:"maxPower,omitempty"`
|
||||
MaxCurrent float64 `json:"maxCurrent,omitempty"`
|
||||
Dimmed bool `json:"dimmed"`
|
||||
}
|
||||
|
||||
// publishCircuits returns a list of circuit titles
|
||||
|
|
@ -30,6 +31,7 @@ func (site *Site) publishCircuits() {
|
|||
Power: instance.GetChargePower(),
|
||||
MaxPower: instance.GetMaxPower(),
|
||||
MaxCurrent: instance.GetMaxCurrent(),
|
||||
Dimmed: instance.Dimmed(),
|
||||
}
|
||||
|
||||
if instance.GetMaxCurrent() > 0 {
|
||||
|
|
|
|||
|
|
@ -222,5 +222,6 @@ func (c *EEBus) setStatusAndLimit(status status, limit float64) {
|
|||
}
|
||||
|
||||
func (c *EEBus) setLimit(limit float64) {
|
||||
c.root.Dim(limit > 0)
|
||||
c.root.SetMaxPower(limit)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -95,6 +95,7 @@ func (c *Relay) run() error {
|
|||
power = c.maxPower
|
||||
}
|
||||
|
||||
c.root.Dim(limit)
|
||||
c.root.SetMaxPower(power)
|
||||
|
||||
return nil
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue