Powerwall: add max charge/discharge power (#23686)
This commit is contained in:
parent
e8486cb1fe
commit
56f033bd72
3 changed files with 408 additions and 21 deletions
|
|
@ -31,7 +31,7 @@ func init() {
|
|||
registry.Add("powerwall", NewPowerWallFromConfig)
|
||||
}
|
||||
|
||||
//go:generate go tool decorate -f decoratePowerWall -b *PowerWall -r api.Meter -t "api.MeterEnergy,TotalEnergy,func() (float64, error)" -t "api.Battery,Soc,func() (float64, error)" -t "api.BatteryCapacity,Capacity,func() float64" -t "api.BatterySocLimiter,GetSocLimits,func() (float64, float64)" -t "api.BatteryController,SetBatteryMode,func(api.BatteryMode) error"
|
||||
//go:generate go tool decorate -f decoratePowerWall -b *PowerWall -r api.Meter -t "api.MeterEnergy,TotalEnergy,func() (float64, error)" -t "api.Battery,Soc,func() (float64, error)" -t "api.BatteryCapacity,Capacity,func() float64" -t "api.BatterySocLimiter,GetSocLimits,func() (float64, float64)" -t "api.BatteryPowerLimiter,GetPowerLimits,func() (float64, float64)" -t "api.BatteryController,SetBatteryMode,func(api.BatteryMode) error"
|
||||
|
||||
// NewPowerWallFromConfig creates a PowerWall Powerwall Meter from generic config
|
||||
func NewPowerWallFromConfig(other map[string]interface{}) (api.Meter, error) {
|
||||
|
|
@ -41,11 +41,16 @@ func NewPowerWallFromConfig(other map[string]interface{}) (api.Meter, error) {
|
|||
RefreshToken string
|
||||
SiteId int64
|
||||
batterySocLimits `mapstructure:",squash"`
|
||||
batteryPowerLimits `mapstructure:",squash"`
|
||||
}{
|
||||
batterySocLimits: batterySocLimits{
|
||||
MinSoc: 20,
|
||||
MaxSoc: 95,
|
||||
},
|
||||
batteryPowerLimits: batteryPowerLimits{
|
||||
MaxChargePower: 4600,
|
||||
MaxDischargePower: 4600,
|
||||
},
|
||||
Cache: time.Second,
|
||||
}
|
||||
|
||||
|
|
@ -69,11 +74,11 @@ func NewPowerWallFromConfig(other map[string]interface{}) (api.Meter, error) {
|
|||
cc.Usage = "solar"
|
||||
}
|
||||
|
||||
return NewPowerWall(cc.URI, cc.Usage, cc.User, cc.Password, cc.Cache, cc.RefreshToken, cc.SiteId, cc.batterySocLimits)
|
||||
return NewPowerWall(cc.URI, cc.Usage, cc.User, cc.Password, cc.Cache, cc.RefreshToken, cc.SiteId, cc.batterySocLimits, cc.batteryPowerLimits)
|
||||
}
|
||||
|
||||
// NewPowerWall creates a Tesla PowerWall Meter
|
||||
func NewPowerWall(uri, usage, user, password string, cache time.Duration, refreshToken string, siteId int64, batterySocLimits batterySocLimits) (api.Meter, error) {
|
||||
func NewPowerWall(uri, usage, user, password string, cache time.Duration, refreshToken string, siteId int64, batterySocLimits batterySocLimits, batteryPowerLimits batteryPowerLimits) (api.Meter, error) {
|
||||
log := util.NewLogger("powerwall").Redact(user, password, refreshToken)
|
||||
|
||||
httpClient := &http.Client{
|
||||
|
|
@ -146,10 +151,12 @@ func NewPowerWall(uri, usage, user, password string, cache time.Duration, refres
|
|||
var batteryCapacity func() float64
|
||||
var batterySoc func() (float64, error)
|
||||
var batterySocLimiter func() (float64, float64)
|
||||
var batteryPowerLimiter func() (float64, float64)
|
||||
|
||||
if usage == "battery" {
|
||||
batterySoc = m.batterySoc
|
||||
batterySocLimiter = batterySocLimits.Decorator()
|
||||
batteryPowerLimiter = batteryPowerLimits.Decorator()
|
||||
|
||||
res, err := m.client.GetSystemStatus()
|
||||
if err != nil {
|
||||
|
|
@ -176,7 +183,7 @@ func NewPowerWall(uri, usage, user, password string, cache time.Duration, refres
|
|||
})
|
||||
}
|
||||
|
||||
return decoratePowerWall(m, totalEnergy, batterySoc, batteryCapacity, batterySocLimiter, batModeS), nil
|
||||
return decoratePowerWall(m, totalEnergy, batterySoc, batteryCapacity, batterySocLimiter, batteryPowerLimiter, batModeS), nil
|
||||
}
|
||||
|
||||
var _ api.Meter = (*PowerWall)(nil)
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import (
|
|||
"github.com/evcc-io/evcc/api"
|
||||
)
|
||||
|
||||
func decoratePowerWall(base *PowerWall, meterEnergy func() (float64, error), battery func() (float64, error), batteryCapacity func() float64, batterySocLimiter func() (float64, float64), batteryController func(api.BatteryMode) error) api.Meter {
|
||||
func decoratePowerWall(base *PowerWall, meterEnergy func() (float64, error), battery func() (float64, error), batteryCapacity func() float64, batterySocLimiter func() (float64, float64), batteryPowerLimiter func() (float64, float64), batteryController func(api.BatteryMode) error) api.Meter {
|
||||
switch {
|
||||
case battery == nil && meterEnergy == nil:
|
||||
return base
|
||||
|
|
@ -22,7 +22,7 @@ func decoratePowerWall(base *PowerWall, meterEnergy func() (float64, error), bat
|
|||
},
|
||||
}
|
||||
|
||||
case battery != nil && batteryCapacity == nil && batteryController == nil && batterySocLimiter == nil && meterEnergy == nil:
|
||||
case battery != nil && batteryCapacity == nil && batteryController == nil && batteryPowerLimiter == nil && batterySocLimiter == nil && meterEnergy == nil:
|
||||
return &struct {
|
||||
*PowerWall
|
||||
api.Battery
|
||||
|
|
@ -33,7 +33,7 @@ func decoratePowerWall(base *PowerWall, meterEnergy func() (float64, error), bat
|
|||
},
|
||||
}
|
||||
|
||||
case battery != nil && batteryCapacity == nil && batteryController == nil && batterySocLimiter == nil && meterEnergy != nil:
|
||||
case battery != nil && batteryCapacity == nil && batteryController == nil && batteryPowerLimiter == nil && batterySocLimiter == nil && meterEnergy != nil:
|
||||
return &struct {
|
||||
*PowerWall
|
||||
api.Battery
|
||||
|
|
@ -48,7 +48,7 @@ func decoratePowerWall(base *PowerWall, meterEnergy func() (float64, error), bat
|
|||
},
|
||||
}
|
||||
|
||||
case battery != nil && batteryCapacity != nil && batteryController == nil && batterySocLimiter == nil && meterEnergy == nil:
|
||||
case battery != nil && batteryCapacity != nil && batteryController == nil && batteryPowerLimiter == nil && batterySocLimiter == nil && meterEnergy == nil:
|
||||
return &struct {
|
||||
*PowerWall
|
||||
api.Battery
|
||||
|
|
@ -63,7 +63,7 @@ func decoratePowerWall(base *PowerWall, meterEnergy func() (float64, error), bat
|
|||
},
|
||||
}
|
||||
|
||||
case battery != nil && batteryCapacity != nil && batteryController == nil && batterySocLimiter == nil && meterEnergy != nil:
|
||||
case battery != nil && batteryCapacity != nil && batteryController == nil && batteryPowerLimiter == nil && batterySocLimiter == nil && meterEnergy != nil:
|
||||
return &struct {
|
||||
*PowerWall
|
||||
api.Battery
|
||||
|
|
@ -82,7 +82,7 @@ func decoratePowerWall(base *PowerWall, meterEnergy func() (float64, error), bat
|
|||
},
|
||||
}
|
||||
|
||||
case battery != nil && batteryCapacity == nil && batteryController == nil && batterySocLimiter != nil && meterEnergy == nil:
|
||||
case battery != nil && batteryCapacity == nil && batteryController == nil && batteryPowerLimiter == nil && batterySocLimiter != nil && meterEnergy == nil:
|
||||
return &struct {
|
||||
*PowerWall
|
||||
api.Battery
|
||||
|
|
@ -97,7 +97,7 @@ func decoratePowerWall(base *PowerWall, meterEnergy func() (float64, error), bat
|
|||
},
|
||||
}
|
||||
|
||||
case battery != nil && batteryCapacity == nil && batteryController == nil && batterySocLimiter != nil && meterEnergy != nil:
|
||||
case battery != nil && batteryCapacity == nil && batteryController == nil && batteryPowerLimiter == nil && batterySocLimiter != nil && meterEnergy != nil:
|
||||
return &struct {
|
||||
*PowerWall
|
||||
api.Battery
|
||||
|
|
@ -116,7 +116,7 @@ func decoratePowerWall(base *PowerWall, meterEnergy func() (float64, error), bat
|
|||
},
|
||||
}
|
||||
|
||||
case battery != nil && batteryCapacity != nil && batteryController == nil && batterySocLimiter != nil && meterEnergy == nil:
|
||||
case battery != nil && batteryCapacity != nil && batteryController == nil && batteryPowerLimiter == nil && batterySocLimiter != nil && meterEnergy == nil:
|
||||
return &struct {
|
||||
*PowerWall
|
||||
api.Battery
|
||||
|
|
@ -135,7 +135,7 @@ func decoratePowerWall(base *PowerWall, meterEnergy func() (float64, error), bat
|
|||
},
|
||||
}
|
||||
|
||||
case battery != nil && batteryCapacity != nil && batteryController == nil && batterySocLimiter != nil && meterEnergy != nil:
|
||||
case battery != nil && batteryCapacity != nil && batteryController == nil && batteryPowerLimiter == nil && batterySocLimiter != nil && meterEnergy != nil:
|
||||
return &struct {
|
||||
*PowerWall
|
||||
api.Battery
|
||||
|
|
@ -158,7 +158,175 @@ func decoratePowerWall(base *PowerWall, meterEnergy func() (float64, error), bat
|
|||
},
|
||||
}
|
||||
|
||||
case battery != nil && batteryCapacity == nil && batteryController != nil && batterySocLimiter == nil && meterEnergy == nil:
|
||||
case battery != nil && batteryCapacity == nil && batteryController == nil && batteryPowerLimiter != nil && batterySocLimiter == nil && meterEnergy == nil:
|
||||
return &struct {
|
||||
*PowerWall
|
||||
api.Battery
|
||||
api.BatteryPowerLimiter
|
||||
}{
|
||||
PowerWall: base,
|
||||
Battery: &decoratePowerWallBatteryImpl{
|
||||
battery: battery,
|
||||
},
|
||||
BatteryPowerLimiter: &decoratePowerWallBatteryPowerLimiterImpl{
|
||||
batteryPowerLimiter: batteryPowerLimiter,
|
||||
},
|
||||
}
|
||||
|
||||
case battery != nil && batteryCapacity == nil && batteryController == nil && batteryPowerLimiter != nil && batterySocLimiter == nil && meterEnergy != nil:
|
||||
return &struct {
|
||||
*PowerWall
|
||||
api.Battery
|
||||
api.BatteryPowerLimiter
|
||||
api.MeterEnergy
|
||||
}{
|
||||
PowerWall: base,
|
||||
Battery: &decoratePowerWallBatteryImpl{
|
||||
battery: battery,
|
||||
},
|
||||
BatteryPowerLimiter: &decoratePowerWallBatteryPowerLimiterImpl{
|
||||
batteryPowerLimiter: batteryPowerLimiter,
|
||||
},
|
||||
MeterEnergy: &decoratePowerWallMeterEnergyImpl{
|
||||
meterEnergy: meterEnergy,
|
||||
},
|
||||
}
|
||||
|
||||
case battery != nil && batteryCapacity != nil && batteryController == nil && batteryPowerLimiter != nil && batterySocLimiter == nil && meterEnergy == nil:
|
||||
return &struct {
|
||||
*PowerWall
|
||||
api.Battery
|
||||
api.BatteryCapacity
|
||||
api.BatteryPowerLimiter
|
||||
}{
|
||||
PowerWall: base,
|
||||
Battery: &decoratePowerWallBatteryImpl{
|
||||
battery: battery,
|
||||
},
|
||||
BatteryCapacity: &decoratePowerWallBatteryCapacityImpl{
|
||||
batteryCapacity: batteryCapacity,
|
||||
},
|
||||
BatteryPowerLimiter: &decoratePowerWallBatteryPowerLimiterImpl{
|
||||
batteryPowerLimiter: batteryPowerLimiter,
|
||||
},
|
||||
}
|
||||
|
||||
case battery != nil && batteryCapacity != nil && batteryController == nil && batteryPowerLimiter != nil && batterySocLimiter == nil && meterEnergy != nil:
|
||||
return &struct {
|
||||
*PowerWall
|
||||
api.Battery
|
||||
api.BatteryCapacity
|
||||
api.BatteryPowerLimiter
|
||||
api.MeterEnergy
|
||||
}{
|
||||
PowerWall: base,
|
||||
Battery: &decoratePowerWallBatteryImpl{
|
||||
battery: battery,
|
||||
},
|
||||
BatteryCapacity: &decoratePowerWallBatteryCapacityImpl{
|
||||
batteryCapacity: batteryCapacity,
|
||||
},
|
||||
BatteryPowerLimiter: &decoratePowerWallBatteryPowerLimiterImpl{
|
||||
batteryPowerLimiter: batteryPowerLimiter,
|
||||
},
|
||||
MeterEnergy: &decoratePowerWallMeterEnergyImpl{
|
||||
meterEnergy: meterEnergy,
|
||||
},
|
||||
}
|
||||
|
||||
case battery != nil && batteryCapacity == nil && batteryController == nil && batteryPowerLimiter != nil && batterySocLimiter != nil && meterEnergy == nil:
|
||||
return &struct {
|
||||
*PowerWall
|
||||
api.Battery
|
||||
api.BatteryPowerLimiter
|
||||
api.BatterySocLimiter
|
||||
}{
|
||||
PowerWall: base,
|
||||
Battery: &decoratePowerWallBatteryImpl{
|
||||
battery: battery,
|
||||
},
|
||||
BatteryPowerLimiter: &decoratePowerWallBatteryPowerLimiterImpl{
|
||||
batteryPowerLimiter: batteryPowerLimiter,
|
||||
},
|
||||
BatterySocLimiter: &decoratePowerWallBatterySocLimiterImpl{
|
||||
batterySocLimiter: batterySocLimiter,
|
||||
},
|
||||
}
|
||||
|
||||
case battery != nil && batteryCapacity == nil && batteryController == nil && batteryPowerLimiter != nil && batterySocLimiter != nil && meterEnergy != nil:
|
||||
return &struct {
|
||||
*PowerWall
|
||||
api.Battery
|
||||
api.BatteryPowerLimiter
|
||||
api.BatterySocLimiter
|
||||
api.MeterEnergy
|
||||
}{
|
||||
PowerWall: base,
|
||||
Battery: &decoratePowerWallBatteryImpl{
|
||||
battery: battery,
|
||||
},
|
||||
BatteryPowerLimiter: &decoratePowerWallBatteryPowerLimiterImpl{
|
||||
batteryPowerLimiter: batteryPowerLimiter,
|
||||
},
|
||||
BatterySocLimiter: &decoratePowerWallBatterySocLimiterImpl{
|
||||
batterySocLimiter: batterySocLimiter,
|
||||
},
|
||||
MeterEnergy: &decoratePowerWallMeterEnergyImpl{
|
||||
meterEnergy: meterEnergy,
|
||||
},
|
||||
}
|
||||
|
||||
case battery != nil && batteryCapacity != nil && batteryController == nil && batteryPowerLimiter != nil && batterySocLimiter != nil && meterEnergy == nil:
|
||||
return &struct {
|
||||
*PowerWall
|
||||
api.Battery
|
||||
api.BatteryCapacity
|
||||
api.BatteryPowerLimiter
|
||||
api.BatterySocLimiter
|
||||
}{
|
||||
PowerWall: base,
|
||||
Battery: &decoratePowerWallBatteryImpl{
|
||||
battery: battery,
|
||||
},
|
||||
BatteryCapacity: &decoratePowerWallBatteryCapacityImpl{
|
||||
batteryCapacity: batteryCapacity,
|
||||
},
|
||||
BatteryPowerLimiter: &decoratePowerWallBatteryPowerLimiterImpl{
|
||||
batteryPowerLimiter: batteryPowerLimiter,
|
||||
},
|
||||
BatterySocLimiter: &decoratePowerWallBatterySocLimiterImpl{
|
||||
batterySocLimiter: batterySocLimiter,
|
||||
},
|
||||
}
|
||||
|
||||
case battery != nil && batteryCapacity != nil && batteryController == nil && batteryPowerLimiter != nil && batterySocLimiter != nil && meterEnergy != nil:
|
||||
return &struct {
|
||||
*PowerWall
|
||||
api.Battery
|
||||
api.BatteryCapacity
|
||||
api.BatteryPowerLimiter
|
||||
api.BatterySocLimiter
|
||||
api.MeterEnergy
|
||||
}{
|
||||
PowerWall: base,
|
||||
Battery: &decoratePowerWallBatteryImpl{
|
||||
battery: battery,
|
||||
},
|
||||
BatteryCapacity: &decoratePowerWallBatteryCapacityImpl{
|
||||
batteryCapacity: batteryCapacity,
|
||||
},
|
||||
BatteryPowerLimiter: &decoratePowerWallBatteryPowerLimiterImpl{
|
||||
batteryPowerLimiter: batteryPowerLimiter,
|
||||
},
|
||||
BatterySocLimiter: &decoratePowerWallBatterySocLimiterImpl{
|
||||
batterySocLimiter: batterySocLimiter,
|
||||
},
|
||||
MeterEnergy: &decoratePowerWallMeterEnergyImpl{
|
||||
meterEnergy: meterEnergy,
|
||||
},
|
||||
}
|
||||
|
||||
case battery != nil && batteryCapacity == nil && batteryController != nil && batteryPowerLimiter == nil && batterySocLimiter == nil && meterEnergy == nil:
|
||||
return &struct {
|
||||
*PowerWall
|
||||
api.Battery
|
||||
|
|
@ -173,7 +341,7 @@ func decoratePowerWall(base *PowerWall, meterEnergy func() (float64, error), bat
|
|||
},
|
||||
}
|
||||
|
||||
case battery != nil && batteryCapacity == nil && batteryController != nil && batterySocLimiter == nil && meterEnergy != nil:
|
||||
case battery != nil && batteryCapacity == nil && batteryController != nil && batteryPowerLimiter == nil && batterySocLimiter == nil && meterEnergy != nil:
|
||||
return &struct {
|
||||
*PowerWall
|
||||
api.Battery
|
||||
|
|
@ -192,7 +360,7 @@ func decoratePowerWall(base *PowerWall, meterEnergy func() (float64, error), bat
|
|||
},
|
||||
}
|
||||
|
||||
case battery != nil && batteryCapacity != nil && batteryController != nil && batterySocLimiter == nil && meterEnergy == nil:
|
||||
case battery != nil && batteryCapacity != nil && batteryController != nil && batteryPowerLimiter == nil && batterySocLimiter == nil && meterEnergy == nil:
|
||||
return &struct {
|
||||
*PowerWall
|
||||
api.Battery
|
||||
|
|
@ -211,7 +379,7 @@ func decoratePowerWall(base *PowerWall, meterEnergy func() (float64, error), bat
|
|||
},
|
||||
}
|
||||
|
||||
case battery != nil && batteryCapacity != nil && batteryController != nil && batterySocLimiter == nil && meterEnergy != nil:
|
||||
case battery != nil && batteryCapacity != nil && batteryController != nil && batteryPowerLimiter == nil && batterySocLimiter == nil && meterEnergy != nil:
|
||||
return &struct {
|
||||
*PowerWall
|
||||
api.Battery
|
||||
|
|
@ -234,7 +402,7 @@ func decoratePowerWall(base *PowerWall, meterEnergy func() (float64, error), bat
|
|||
},
|
||||
}
|
||||
|
||||
case battery != nil && batteryCapacity == nil && batteryController != nil && batterySocLimiter != nil && meterEnergy == nil:
|
||||
case battery != nil && batteryCapacity == nil && batteryController != nil && batteryPowerLimiter == nil && batterySocLimiter != nil && meterEnergy == nil:
|
||||
return &struct {
|
||||
*PowerWall
|
||||
api.Battery
|
||||
|
|
@ -253,7 +421,7 @@ func decoratePowerWall(base *PowerWall, meterEnergy func() (float64, error), bat
|
|||
},
|
||||
}
|
||||
|
||||
case battery != nil && batteryCapacity == nil && batteryController != nil && batterySocLimiter != nil && meterEnergy != nil:
|
||||
case battery != nil && batteryCapacity == nil && batteryController != nil && batteryPowerLimiter == nil && batterySocLimiter != nil && meterEnergy != nil:
|
||||
return &struct {
|
||||
*PowerWall
|
||||
api.Battery
|
||||
|
|
@ -276,7 +444,7 @@ func decoratePowerWall(base *PowerWall, meterEnergy func() (float64, error), bat
|
|||
},
|
||||
}
|
||||
|
||||
case battery != nil && batteryCapacity != nil && batteryController != nil && batterySocLimiter != nil && meterEnergy == nil:
|
||||
case battery != nil && batteryCapacity != nil && batteryController != nil && batteryPowerLimiter == nil && batterySocLimiter != nil && meterEnergy == nil:
|
||||
return &struct {
|
||||
*PowerWall
|
||||
api.Battery
|
||||
|
|
@ -299,7 +467,7 @@ func decoratePowerWall(base *PowerWall, meterEnergy func() (float64, error), bat
|
|||
},
|
||||
}
|
||||
|
||||
case battery != nil && batteryCapacity != nil && batteryController != nil && batterySocLimiter != nil && meterEnergy != nil:
|
||||
case battery != nil && batteryCapacity != nil && batteryController != nil && batteryPowerLimiter == nil && batterySocLimiter != nil && meterEnergy != nil:
|
||||
return &struct {
|
||||
*PowerWall
|
||||
api.Battery
|
||||
|
|
@ -325,6 +493,206 @@ func decoratePowerWall(base *PowerWall, meterEnergy func() (float64, error), bat
|
|||
meterEnergy: meterEnergy,
|
||||
},
|
||||
}
|
||||
|
||||
case battery != nil && batteryCapacity == nil && batteryController != nil && batteryPowerLimiter != nil && batterySocLimiter == nil && meterEnergy == nil:
|
||||
return &struct {
|
||||
*PowerWall
|
||||
api.Battery
|
||||
api.BatteryController
|
||||
api.BatteryPowerLimiter
|
||||
}{
|
||||
PowerWall: base,
|
||||
Battery: &decoratePowerWallBatteryImpl{
|
||||
battery: battery,
|
||||
},
|
||||
BatteryController: &decoratePowerWallBatteryControllerImpl{
|
||||
batteryController: batteryController,
|
||||
},
|
||||
BatteryPowerLimiter: &decoratePowerWallBatteryPowerLimiterImpl{
|
||||
batteryPowerLimiter: batteryPowerLimiter,
|
||||
},
|
||||
}
|
||||
|
||||
case battery != nil && batteryCapacity == nil && batteryController != nil && batteryPowerLimiter != nil && batterySocLimiter == nil && meterEnergy != nil:
|
||||
return &struct {
|
||||
*PowerWall
|
||||
api.Battery
|
||||
api.BatteryController
|
||||
api.BatteryPowerLimiter
|
||||
api.MeterEnergy
|
||||
}{
|
||||
PowerWall: base,
|
||||
Battery: &decoratePowerWallBatteryImpl{
|
||||
battery: battery,
|
||||
},
|
||||
BatteryController: &decoratePowerWallBatteryControllerImpl{
|
||||
batteryController: batteryController,
|
||||
},
|
||||
BatteryPowerLimiter: &decoratePowerWallBatteryPowerLimiterImpl{
|
||||
batteryPowerLimiter: batteryPowerLimiter,
|
||||
},
|
||||
MeterEnergy: &decoratePowerWallMeterEnergyImpl{
|
||||
meterEnergy: meterEnergy,
|
||||
},
|
||||
}
|
||||
|
||||
case battery != nil && batteryCapacity != nil && batteryController != nil && batteryPowerLimiter != nil && batterySocLimiter == nil && meterEnergy == nil:
|
||||
return &struct {
|
||||
*PowerWall
|
||||
api.Battery
|
||||
api.BatteryCapacity
|
||||
api.BatteryController
|
||||
api.BatteryPowerLimiter
|
||||
}{
|
||||
PowerWall: base,
|
||||
Battery: &decoratePowerWallBatteryImpl{
|
||||
battery: battery,
|
||||
},
|
||||
BatteryCapacity: &decoratePowerWallBatteryCapacityImpl{
|
||||
batteryCapacity: batteryCapacity,
|
||||
},
|
||||
BatteryController: &decoratePowerWallBatteryControllerImpl{
|
||||
batteryController: batteryController,
|
||||
},
|
||||
BatteryPowerLimiter: &decoratePowerWallBatteryPowerLimiterImpl{
|
||||
batteryPowerLimiter: batteryPowerLimiter,
|
||||
},
|
||||
}
|
||||
|
||||
case battery != nil && batteryCapacity != nil && batteryController != nil && batteryPowerLimiter != nil && batterySocLimiter == nil && meterEnergy != nil:
|
||||
return &struct {
|
||||
*PowerWall
|
||||
api.Battery
|
||||
api.BatteryCapacity
|
||||
api.BatteryController
|
||||
api.BatteryPowerLimiter
|
||||
api.MeterEnergy
|
||||
}{
|
||||
PowerWall: base,
|
||||
Battery: &decoratePowerWallBatteryImpl{
|
||||
battery: battery,
|
||||
},
|
||||
BatteryCapacity: &decoratePowerWallBatteryCapacityImpl{
|
||||
batteryCapacity: batteryCapacity,
|
||||
},
|
||||
BatteryController: &decoratePowerWallBatteryControllerImpl{
|
||||
batteryController: batteryController,
|
||||
},
|
||||
BatteryPowerLimiter: &decoratePowerWallBatteryPowerLimiterImpl{
|
||||
batteryPowerLimiter: batteryPowerLimiter,
|
||||
},
|
||||
MeterEnergy: &decoratePowerWallMeterEnergyImpl{
|
||||
meterEnergy: meterEnergy,
|
||||
},
|
||||
}
|
||||
|
||||
case battery != nil && batteryCapacity == nil && batteryController != nil && batteryPowerLimiter != nil && batterySocLimiter != nil && meterEnergy == nil:
|
||||
return &struct {
|
||||
*PowerWall
|
||||
api.Battery
|
||||
api.BatteryController
|
||||
api.BatteryPowerLimiter
|
||||
api.BatterySocLimiter
|
||||
}{
|
||||
PowerWall: base,
|
||||
Battery: &decoratePowerWallBatteryImpl{
|
||||
battery: battery,
|
||||
},
|
||||
BatteryController: &decoratePowerWallBatteryControllerImpl{
|
||||
batteryController: batteryController,
|
||||
},
|
||||
BatteryPowerLimiter: &decoratePowerWallBatteryPowerLimiterImpl{
|
||||
batteryPowerLimiter: batteryPowerLimiter,
|
||||
},
|
||||
BatterySocLimiter: &decoratePowerWallBatterySocLimiterImpl{
|
||||
batterySocLimiter: batterySocLimiter,
|
||||
},
|
||||
}
|
||||
|
||||
case battery != nil && batteryCapacity == nil && batteryController != nil && batteryPowerLimiter != nil && batterySocLimiter != nil && meterEnergy != nil:
|
||||
return &struct {
|
||||
*PowerWall
|
||||
api.Battery
|
||||
api.BatteryController
|
||||
api.BatteryPowerLimiter
|
||||
api.BatterySocLimiter
|
||||
api.MeterEnergy
|
||||
}{
|
||||
PowerWall: base,
|
||||
Battery: &decoratePowerWallBatteryImpl{
|
||||
battery: battery,
|
||||
},
|
||||
BatteryController: &decoratePowerWallBatteryControllerImpl{
|
||||
batteryController: batteryController,
|
||||
},
|
||||
BatteryPowerLimiter: &decoratePowerWallBatteryPowerLimiterImpl{
|
||||
batteryPowerLimiter: batteryPowerLimiter,
|
||||
},
|
||||
BatterySocLimiter: &decoratePowerWallBatterySocLimiterImpl{
|
||||
batterySocLimiter: batterySocLimiter,
|
||||
},
|
||||
MeterEnergy: &decoratePowerWallMeterEnergyImpl{
|
||||
meterEnergy: meterEnergy,
|
||||
},
|
||||
}
|
||||
|
||||
case battery != nil && batteryCapacity != nil && batteryController != nil && batteryPowerLimiter != nil && batterySocLimiter != nil && meterEnergy == nil:
|
||||
return &struct {
|
||||
*PowerWall
|
||||
api.Battery
|
||||
api.BatteryCapacity
|
||||
api.BatteryController
|
||||
api.BatteryPowerLimiter
|
||||
api.BatterySocLimiter
|
||||
}{
|
||||
PowerWall: base,
|
||||
Battery: &decoratePowerWallBatteryImpl{
|
||||
battery: battery,
|
||||
},
|
||||
BatteryCapacity: &decoratePowerWallBatteryCapacityImpl{
|
||||
batteryCapacity: batteryCapacity,
|
||||
},
|
||||
BatteryController: &decoratePowerWallBatteryControllerImpl{
|
||||
batteryController: batteryController,
|
||||
},
|
||||
BatteryPowerLimiter: &decoratePowerWallBatteryPowerLimiterImpl{
|
||||
batteryPowerLimiter: batteryPowerLimiter,
|
||||
},
|
||||
BatterySocLimiter: &decoratePowerWallBatterySocLimiterImpl{
|
||||
batterySocLimiter: batterySocLimiter,
|
||||
},
|
||||
}
|
||||
|
||||
case battery != nil && batteryCapacity != nil && batteryController != nil && batteryPowerLimiter != nil && batterySocLimiter != nil && meterEnergy != nil:
|
||||
return &struct {
|
||||
*PowerWall
|
||||
api.Battery
|
||||
api.BatteryCapacity
|
||||
api.BatteryController
|
||||
api.BatteryPowerLimiter
|
||||
api.BatterySocLimiter
|
||||
api.MeterEnergy
|
||||
}{
|
||||
PowerWall: base,
|
||||
Battery: &decoratePowerWallBatteryImpl{
|
||||
battery: battery,
|
||||
},
|
||||
BatteryCapacity: &decoratePowerWallBatteryCapacityImpl{
|
||||
batteryCapacity: batteryCapacity,
|
||||
},
|
||||
BatteryController: &decoratePowerWallBatteryControllerImpl{
|
||||
batteryController: batteryController,
|
||||
},
|
||||
BatteryPowerLimiter: &decoratePowerWallBatteryPowerLimiterImpl{
|
||||
batteryPowerLimiter: batteryPowerLimiter,
|
||||
},
|
||||
BatterySocLimiter: &decoratePowerWallBatterySocLimiterImpl{
|
||||
batterySocLimiter: batterySocLimiter,
|
||||
},
|
||||
MeterEnergy: &decoratePowerWallMeterEnergyImpl{
|
||||
meterEnergy: meterEnergy,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
|
|
@ -354,6 +722,14 @@ func (impl *decoratePowerWallBatteryControllerImpl) SetBatteryMode(p0 api.Batter
|
|||
return impl.batteryController(p0)
|
||||
}
|
||||
|
||||
type decoratePowerWallBatteryPowerLimiterImpl struct {
|
||||
batteryPowerLimiter func() (float64, float64)
|
||||
}
|
||||
|
||||
func (impl *decoratePowerWallBatteryPowerLimiterImpl) GetPowerLimits() (float64, float64) {
|
||||
return impl.batteryPowerLimiter()
|
||||
}
|
||||
|
||||
type decoratePowerWallBatterySocLimiterImpl struct {
|
||||
batterySocLimiter func() (float64, float64)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,6 +43,8 @@ params:
|
|||
- name: maxsoc
|
||||
type: int
|
||||
advanced: true
|
||||
- name: maxchargepower
|
||||
- name: maxdischargepower
|
||||
render: |
|
||||
type: powerwall
|
||||
uri: {{ .host }}
|
||||
|
|
@ -53,3 +55,5 @@ render: |
|
|||
siteId: {{ .siteId }}
|
||||
minsoc: {{ .minsoc }}
|
||||
maxsoc: {{ .maxsoc }}
|
||||
maxchargepower: {{ .maxchargepower }}
|
||||
maxdischargepower: {{ .maxdischargepower }}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue