EEBus OHPCF: add disablepowerlimiter option (#33071)
This commit is contained in:
parent
8edf92a103
commit
469ccb83ab
5 changed files with 52 additions and 11 deletions
|
|
@ -378,6 +378,21 @@ func (i *iPhaseVoltages) Voltages() (float64, float64, float64, error) {
|
||||||
return i.phaseVoltages0()
|
return i.phaseVoltages0()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func PowerLimiter(powerLimiter0 func() (float64, float64, error)) api.PowerLimiter {
|
||||||
|
if powerLimiter0 == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return &iPowerLimiter{powerLimiter0}
|
||||||
|
}
|
||||||
|
|
||||||
|
type iPowerLimiter struct {
|
||||||
|
powerLimiter0 func() (float64, float64, error)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (i *iPowerLimiter) GetMinMaxPower() (float64, float64, error) {
|
||||||
|
return i.powerLimiter0()
|
||||||
|
}
|
||||||
|
|
||||||
func Resurrector(resurrector0 func() error) api.Resurrector {
|
func Resurrector(resurrector0 func() error) api.Resurrector {
|
||||||
if resurrector0 == nil {
|
if resurrector0 == nil {
|
||||||
return nil
|
return nil
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@ import (
|
||||||
spineapi "github.com/enbility/spine-go/api"
|
spineapi "github.com/enbility/spine-go/api"
|
||||||
"github.com/enbility/spine-go/model"
|
"github.com/enbility/spine-go/model"
|
||||||
"github.com/evcc-io/evcc/api"
|
"github.com/evcc-io/evcc/api"
|
||||||
|
"github.com/evcc-io/evcc/api/implement"
|
||||||
"github.com/evcc-io/evcc/server/eebus"
|
"github.com/evcc-io/evcc/server/eebus"
|
||||||
"github.com/evcc-io/evcc/util"
|
"github.com/evcc-io/evcc/util"
|
||||||
)
|
)
|
||||||
|
|
@ -27,6 +28,7 @@ import (
|
||||||
// enabling the charger schedules or resumes the optional consumption, disabling
|
// enabling the charger schedules or resumes the optional consumption, disabling
|
||||||
// it pauses or aborts the running process.
|
// it pauses or aborts the running process.
|
||||||
type EEBusOHPCF struct {
|
type EEBusOHPCF struct {
|
||||||
|
implement.Caps
|
||||||
*embed
|
*embed
|
||||||
cem *eebus.CustomerEnergyManagement
|
cem *eebus.CustomerEnergyManagement
|
||||||
ma *eebus.MonitoringAppliance
|
ma *eebus.MonitoringAppliance
|
||||||
|
|
@ -58,10 +60,11 @@ func init() {
|
||||||
// NewEEBusOHPCFFromConfig creates an EEBus OHPCF charger from generic config
|
// NewEEBusOHPCFFromConfig creates an EEBus OHPCF charger from generic config
|
||||||
func NewEEBusOHPCFFromConfig(ctx context.Context, other map[string]any) (api.Charger, error) {
|
func NewEEBusOHPCFFromConfig(ctx context.Context, other map[string]any) (api.Charger, error) {
|
||||||
cc := struct {
|
cc := struct {
|
||||||
embed `mapstructure:",squash"`
|
embed `mapstructure:",squash"`
|
||||||
Ski string
|
Ski string
|
||||||
Ip string
|
Ip string
|
||||||
Reboost time.Duration
|
Reboost time.Duration
|
||||||
|
DisablePowerLimiter bool
|
||||||
}{
|
}{
|
||||||
embed: embed{
|
embed: embed{
|
||||||
Icon_: "heatpump",
|
Icon_: "heatpump",
|
||||||
|
|
@ -74,18 +77,19 @@ func NewEEBusOHPCFFromConfig(ctx context.Context, other map[string]any) (api.Cha
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return NewEEBusOHPCF(ctx, &cc.embed, cc.Ski, cc.Ip, cc.Reboost)
|
return NewEEBusOHPCF(ctx, &cc.embed, cc.Ski, cc.Ip, cc.Reboost, cc.DisablePowerLimiter)
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewEEBusOHPCF creates an EEBus OHPCF charger, registers it with the EEBus
|
// NewEEBusOHPCF creates an EEBus OHPCF charger, registers it with the EEBus
|
||||||
// instance and waits for the connection.
|
// instance and waits for the connection.
|
||||||
func NewEEBusOHPCF(ctx context.Context, embed *embed, ski, ip string, reboost time.Duration) (api.Charger, error) {
|
func NewEEBusOHPCF(ctx context.Context, embed *embed, ski, ip string, reboost time.Duration, disablePowerLimiter bool) (api.Charger, error) {
|
||||||
inst, err := eebus.Instance()
|
inst, err := eebus.Instance()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
c := &EEBusOHPCF{
|
c := &EEBusOHPCF{
|
||||||
|
Caps: implement.New(),
|
||||||
embed: embed,
|
embed: embed,
|
||||||
log: util.NewLogger("eebus-ohpcf"),
|
log: util.NewLogger("eebus-ohpcf"),
|
||||||
cem: inst.CustomerEnergyManagement(),
|
cem: inst.CustomerEnergyManagement(),
|
||||||
|
|
@ -96,6 +100,10 @@ func NewEEBusOHPCF(ctx context.Context, embed *embed, ski, ip string, reboost ti
|
||||||
reboost: reboost,
|
reboost: reboost,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !disablePowerLimiter {
|
||||||
|
implement.Has(c, implement.PowerLimiter(c.getMinMaxPower))
|
||||||
|
}
|
||||||
|
|
||||||
if err := inst.RegisterDevice(ski, ip, c); err != nil {
|
if err := inst.RegisterDevice(ski, ip, c); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
@ -460,11 +468,8 @@ func (c *EEBusOHPCF) apply(enable bool) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ api.PowerLimiter = (*EEBusOHPCF)(nil)
|
// getMinMaxPower is the callback used to provide the optional power limits.
|
||||||
|
func (c *EEBusOHPCF) getMinMaxPower() (float64, float64, error) {
|
||||||
// GetMinMaxPower implements the api.PowerLimiter interface, reporting the
|
|
||||||
// optional consumption as expected min/max or ErrNotAvailable if none.
|
|
||||||
func (c *EEBusOHPCF) GetMinMaxPower() (float64, float64, error) {
|
|
||||||
entity, ok := c.connectedCompressor()
|
entity, ok := c.connectedCompressor()
|
||||||
if !ok {
|
if !ok {
|
||||||
return 0, 0, errNotConnected
|
return 0, 0, errNotConnected
|
||||||
|
|
|
||||||
|
|
@ -86,6 +86,7 @@ func generate(out io.Writer) error {
|
||||||
reflect.TypeFor[api.PhasePowers](),
|
reflect.TypeFor[api.PhasePowers](),
|
||||||
reflect.TypeFor[api.PhaseSwitcher](),
|
reflect.TypeFor[api.PhaseSwitcher](),
|
||||||
reflect.TypeFor[api.PhaseVoltages](),
|
reflect.TypeFor[api.PhaseVoltages](),
|
||||||
|
reflect.TypeFor[api.PowerLimiter](),
|
||||||
reflect.TypeFor[api.Resurrector](),
|
reflect.TypeFor[api.Resurrector](),
|
||||||
reflect.TypeFor[api.SocLimiter](),
|
reflect.TypeFor[api.SocLimiter](),
|
||||||
reflect.TypeFor[api.StatusReasoner](),
|
reflect.TypeFor[api.StatusReasoner](),
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,17 @@ params:
|
||||||
help:
|
help:
|
||||||
de: Wartezeit, nach der eine neu angekündigte optionale Leistungsaufnahme erneut eingeplant wird.
|
de: Wartezeit, nach der eine neu angekündigte optionale Leistungsaufnahme erneut eingeplant wird.
|
||||||
en: Wait time after which a newly announced optional power consumption is scheduled again.
|
en: Wait time after which a newly announced optional power consumption is scheduled again.
|
||||||
|
- name: disablepowerlimiter
|
||||||
|
type: bool
|
||||||
|
advanced: true
|
||||||
|
description:
|
||||||
|
de: Leistungsgrenzen ignorieren
|
||||||
|
en: Ignore power limits
|
||||||
|
help:
|
||||||
|
de: Die vom Gerät gemeldete optionale Leistungsaufnahme nicht als Min-/Max-Leistung verwenden.
|
||||||
|
en: Do not use the device's announced optional power consumption as min/max power.
|
||||||
render: |
|
render: |
|
||||||
type: eebus-ohpcf
|
type: eebus-ohpcf
|
||||||
{{ include "eebus" . }}
|
{{ include "eebus" . }}
|
||||||
reboost: {{ .reboost }}
|
reboost: {{ .reboost }}
|
||||||
|
disablepowerlimiter: {{ .disablepowerlimiter }}
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,17 @@ params:
|
||||||
help:
|
help:
|
||||||
de: Wartezeit, nach der eine neu angekündigte optionale Leistungsaufnahme erneut eingeplant wird.
|
de: Wartezeit, nach der eine neu angekündigte optionale Leistungsaufnahme erneut eingeplant wird.
|
||||||
en: Wait time after which a newly announced optional power consumption is scheduled again.
|
en: Wait time after which a newly announced optional power consumption is scheduled again.
|
||||||
|
- name: disablepowerlimiter
|
||||||
|
type: bool
|
||||||
|
advanced: true
|
||||||
|
description:
|
||||||
|
de: Leistungsgrenzen ignorieren
|
||||||
|
en: Ignore power limits
|
||||||
|
help:
|
||||||
|
de: Die vom Gerät gemeldete optionale Leistungsaufnahme nicht als Min-/Max-Leistung verwenden.
|
||||||
|
en: Do not use the device's announced optional power consumption as min/max power.
|
||||||
render: |
|
render: |
|
||||||
type: eebus-ohpcf
|
type: eebus-ohpcf
|
||||||
{{ include "eebus" . }}
|
{{ include "eebus" . }}
|
||||||
reboost: {{ .reboost }}
|
reboost: {{ .reboost }}
|
||||||
|
disablepowerlimiter: {{ .disablepowerlimiter }}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue