HEMS: make Dimmed/Curtailed tri-state (once more) (#30712)
This commit is contained in:
parent
d859ae9c7c
commit
45cab34ce9
10 changed files with 32 additions and 31 deletions
|
|
@ -294,17 +294,17 @@ func (c *EEBus) setProductionLimit(limit float64, active bool) {
|
|||
var _ api.HEMS = (*EEBus)(nil)
|
||||
|
||||
// Dimmed implements api.HEMS, derived from consumptionLimitActivated.
|
||||
func (c *EEBus) Dimmed() bool {
|
||||
func (c *EEBus) Dimmed() *bool {
|
||||
c.mux.RLock()
|
||||
defer c.mux.RUnlock()
|
||||
return !c.consumptionLimitActivated.IsZero()
|
||||
return new(!c.consumptionLimitActivated.IsZero())
|
||||
}
|
||||
|
||||
// Curtailed implements api.HEMS, derived from productionLimitActivated.
|
||||
func (c *EEBus) Curtailed() bool {
|
||||
func (c *EEBus) Curtailed() *bool {
|
||||
c.mux.RLock()
|
||||
defer c.mux.RUnlock()
|
||||
return !c.productionLimitActivated.IsZero()
|
||||
return new(!c.productionLimitActivated.IsZero())
|
||||
}
|
||||
|
||||
// MaxConsumptionPower implements api.HEMS, returning the consumption cap
|
||||
|
|
|
|||
|
|
@ -49,14 +49,14 @@ func newTestEEBus(t *testing.T) *EEBus {
|
|||
// assertConsumptionLimit checks the HEMS consumption state through the api.HEMS surface.
|
||||
func assertConsumptionLimit(t *testing.T, c *EEBus, limit float64) {
|
||||
t.Helper()
|
||||
assert.Equal(t, limit > 0, c.Dimmed())
|
||||
assert.Equal(t, new(limit > 0), c.Dimmed())
|
||||
assert.Equal(t, limit, c.MaxConsumptionPower())
|
||||
}
|
||||
|
||||
// assertProductionLimit checks the HEMS production state through the api.HEMS surface.
|
||||
func assertProductionLimit(t *testing.T, c *EEBus, active bool) {
|
||||
t.Helper()
|
||||
assert.Equal(t, active, c.Curtailed())
|
||||
assert.Equal(t, new(active), c.Curtailed())
|
||||
}
|
||||
|
||||
// TestRun_HeartbeatLost_EntersFailsafe verifies the LPC-911/LPP-911 transition:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue