Documentation ¶
Index ¶
- Constants
- Variables
- type EnergyMetrics
- func (em *EnergyMetrics) Co2PerKWh() *float64
- func (em *EnergyMetrics) Price() *float64
- func (em *EnergyMetrics) PricePerKWh() *float64
- func (em *EnergyMetrics) Publish(prefix string, p publisher)
- func (em *EnergyMetrics) Reset()
- func (em *EnergyMetrics) SetEnvironment(greenShare float64, effPrice, effCo2 *float64)
- func (em *EnergyMetrics) SolarPercentage() float64
- func (em *EnergyMetrics) TotalWh() float64
- func (em *EnergyMetrics) Update(chargedKWh float64) (float64, float64)
- type Health
- type Loadpoint
- func (lp *Loadpoint) ActivePhases() int
- func (lp *Loadpoint) EffectiveMaxPower() float64
- func (lp *Loadpoint) EffectiveMinPower() float64
- func (lp *Loadpoint) EffectivePlanId() int
- func (lp *Loadpoint) EffectivePlanSoc() int
- func (lp *Loadpoint) EffectivePlanTime() time.Time
- func (lp *Loadpoint) EffectivePriority() int
- func (lp *Loadpoint) GetBatteryBoost() bool
- func (lp *Loadpoint) GetChargePower() float64
- func (lp *Loadpoint) GetChargePowerFlexibility() float64
- func (lp *Loadpoint) GetCircuit() api.Circuit
- func (lp *Loadpoint) GetDisableDelay() time.Duration
- func (lp *Loadpoint) GetDisableThreshold() float64
- func (lp *Loadpoint) GetEnableDelay() time.Duration
- func (lp *Loadpoint) GetEnableThreshold() float64
- func (lp *Loadpoint) GetLimitEnergy() float64
- func (lp *Loadpoint) GetLimitSoc() int
- func (lp *Loadpoint) GetMaxCurrent() float64
- func (lp *Loadpoint) GetMaxPhaseCurrent() float64
- func (lp *Loadpoint) GetMaxPower() float64
- func (lp *Loadpoint) GetMinCurrent() float64
- func (lp *Loadpoint) GetMinPower() float64
- func (lp *Loadpoint) GetMode() api.ChargeMode
- func (lp *Loadpoint) GetPhases() int
- func (lp *Loadpoint) GetPlan(targetTime time.Time, requiredDuration time.Duration) (api.Rates, error)
- func (lp *Loadpoint) GetPlanEnergy() (time.Time, float64)
- func (lp *Loadpoint) GetPlanGoal() (float64, bool)
- func (lp *Loadpoint) GetPlanRequiredDuration(goal, maxPower float64) time.Duration
- func (lp *Loadpoint) GetPriority() int
- func (lp *Loadpoint) GetRemainingDuration() time.Duration
- func (lp *Loadpoint) GetRemainingEnergy() float64
- func (lp *Loadpoint) GetSmartCostLimit() *float64
- func (lp *Loadpoint) GetStatus() api.ChargeStatus
- func (lp *Loadpoint) GetVehicle() api.Vehicle
- func (lp *Loadpoint) HasChargeMeter() bool
- func (lp *Loadpoint) IsFastChargingActive() bool
- func (lp *Loadpoint) Prepare(uiChan chan<- util.Param, pushChan chan<- push.Event, lpChan chan<- *Loadpoint)
- func (lp *Loadpoint) PublishEffectiveValues()
- func (lp *Loadpoint) RemoteControl(source string, demand loadpoint.RemoteDemand)
- func (lp *Loadpoint) SetBatteryBoost(enable bool) error
- func (lp *Loadpoint) SetDisableDelay(delay time.Duration)
- func (lp *Loadpoint) SetDisableThreshold(threshold float64)
- func (lp *Loadpoint) SetEnableDelay(delay time.Duration)
- func (lp *Loadpoint) SetEnableThreshold(threshold float64)
- func (lp *Loadpoint) SetLimitEnergy(energy float64)
- func (lp *Loadpoint) SetLimitSoc(soc int)
- func (lp *Loadpoint) SetMaxCurrent(current float64) error
- func (lp *Loadpoint) SetMinCurrent(current float64) error
- func (lp *Loadpoint) SetMode(mode api.ChargeMode)
- func (lp *Loadpoint) SetPhases(phases int) error
- func (lp *Loadpoint) SetPlanEnergy(finishAt time.Time, energy float64) error
- func (lp *Loadpoint) SetPriority(prio int)
- func (lp *Loadpoint) SetRemainingDuration(chargeRemainingDuration time.Duration)
- func (lp *Loadpoint) SetRemainingEnergy(chargeRemainingEnergy float64)
- func (lp *Loadpoint) SetSmartCostLimit(val *float64)
- func (lp *Loadpoint) SetVehicle(vehicle api.Vehicle)
- func (lp *Loadpoint) SocBasedPlanning() bool
- func (lp *Loadpoint) StartVehicleDetection()
- func (lp *Loadpoint) Title() string
- func (lp *Loadpoint) Update(sitePower, batteryBoostPower float64, rates api.Rates, ...)
- func (lp *Loadpoint) UpdateChargePowerAndCurrents() float64
- type MetersConfig
- type PollConfig
- type Progress
- type Settings
- func (s *Settings) Bool(key string) (bool, error)
- func (s *Settings) Float(key string) (float64, error)
- func (s *Settings) Int(key string) (int64, error)
- func (s *Settings) SetBool(key string, val bool)
- func (s *Settings) SetFloat(key string, val float64)
- func (s *Settings) SetInt(key string, val int64)
- func (s *Settings) SetString(key string, val string)
- func (s *Settings) SetTime(key string, val time.Time)
- func (s *Settings) String(key string) (string, error)
- func (s *Settings) Time(key string) (time.Time, error)
- type Site
- func (site *Site) Boot(log *util.Logger, loadpoints []*Loadpoint, tariffs *tariff.Tariffs) error
- func (site *Site) DumpConfig()
- func (site *Site) GetAuxMeterRefs() []string
- func (site *Site) GetBatteryDischargeControl() bool
- func (site *Site) GetBatteryGridChargeLimit() *float64
- func (site *Site) GetBatteryMeterRefs() []string
- func (site *Site) GetBatteryMode() api.BatteryMode
- func (site *Site) GetBufferSoc() float64
- func (site *Site) GetBufferStartSoc() float64
- func (site *Site) GetCircuit() api.Circuit
- func (site *Site) GetGridMeterRef() string
- func (site *Site) GetPVMeterRefs() []string
- func (site *Site) GetPrioritySoc() float64
- func (site *Site) GetResidualPower() float64
- func (site *Site) GetTariff(tariff string) api.Tariff
- func (site *Site) GetTitle() string
- func (site *Site) Loadpoints() []loadpoint.API
- func (site *Site) Prepare(uiChan chan<- util.Param, pushChan chan<- push.Event)
- func (site *Site) Run(stopC chan struct{}, interval time.Duration)
- func (site *Site) SetAuxMeterRefs(ref []string)
- func (site *Site) SetBatteryDischargeControl(val bool) error
- func (site *Site) SetBatteryGridChargeLimit(val *float64)
- func (site *Site) SetBatteryMeterRefs(ref []string)
- func (site *Site) SetBatteryMode(batMode api.BatteryMode)
- func (site *Site) SetBufferSoc(soc float64) error
- func (site *Site) SetBufferStartSoc(soc float64) error
- func (site *Site) SetCircuit(circuit api.Circuit)
- func (site *Site) SetGridMeterRef(ref string)
- func (site *Site) SetPVMeterRefs(ref []string)
- func (site *Site) SetPrioritySoc(soc float64) error
- func (site *Site) SetResidualPower(power float64) error
- func (site *Site) SetTitle(title string)
- func (site *Site) Vehicles() site.Vehicles
- type SocConfig
- type Stats
- type Task
- type ThresholdConfig
- type Timer
Constants ¶
const ( GridTariff = "grid" FeedinTariff = "feedin" PlannerTariff = "planner" )
Variables ¶
var ErrBatteryNotConfigured = errors.New("battery not configured")
var ( // Voltage global value Voltage float64 )
Functions ¶
This section is empty.
Types ¶
type EnergyMetrics ¶
type EnergyMetrics struct {
// contains filtered or unexported fields
}
EnergyMetrics calculates stats about the charged energy and gives you details about price or co2s
func NewEnergyMetrics ¶
func NewEnergyMetrics() *EnergyMetrics
func (*EnergyMetrics) Co2PerKWh ¶
func (em *EnergyMetrics) Co2PerKWh() *float64
Co2PerKWh returns the average co2 emissions per kWh
func (*EnergyMetrics) Price ¶
func (em *EnergyMetrics) Price() *float64
Price returns the total energy price in Currency
func (*EnergyMetrics) PricePerKWh ¶
func (em *EnergyMetrics) PricePerKWh() *float64
PricePerKWh returns the average energy price in Currency
func (*EnergyMetrics) Publish ¶
func (em *EnergyMetrics) Publish(prefix string, p publisher)
Publish publishes metrics with a given prefix
func (*EnergyMetrics) Reset ¶
func (em *EnergyMetrics) Reset()
Reset sets all calculations to initial values
func (*EnergyMetrics) SetEnvironment ¶
func (em *EnergyMetrics) SetEnvironment(greenShare float64, effPrice, effCo2 *float64)
SetEnvironment updates site information like solar share, price, co2 for use in later calculations
func (*EnergyMetrics) SolarPercentage ¶
func (em *EnergyMetrics) SolarPercentage() float64
SolarPercentage returns the share of self-produced energy in percent
func (*EnergyMetrics) TotalWh ¶
func (em *EnergyMetrics) TotalWh() float64
TotalWh returns the total energy in Wh
type Health ¶
type Health struct {
// contains filtered or unexported fields
}
Health is a health checker that needs regular updates to stay healthy
type Loadpoint ¶
type Loadpoint struct { // exposed public configuration sync.RWMutex // guard status Mode_ api.ChargeMode `mapstructure:"mode"` // Default charge mode, used for disconnect Title_ string `mapstructure:"title"` // UI title Priority_ int `mapstructure:"priority"` // Priority CircuitRef string `mapstructure:"circuit"` // Circuit reference ChargerRef string `mapstructure:"charger"` // Charger reference VehicleRef string `mapstructure:"vehicle"` // Vehicle reference MeterRef string `mapstructure:"meter"` // Charge meter reference Soc SocConfig Enable, Disable ThresholdConfig // TODO deprecated GuardDuration_ time.Duration `mapstructure:"guardduration"` // charger enable/disable minimum holding time ConfiguredPhases_ int `mapstructure:"phases"` MinCurrent_ float64 `mapstructure:"minCurrent"` MaxCurrent_ float64 `mapstructure:"maxCurrent"` // contains filtered or unexported fields }
Loadpoint is responsible for controlling charge depending on Soc needs and power availability.
func NewLoadpoint ¶
NewLoadpoint creates a Loadpoint with sane defaults
func NewLoadpointFromConfig ¶
func NewLoadpointFromConfig(log *util.Logger, settings *Settings, other map[string]interface{}) (*Loadpoint, error)
NewLoadpointFromConfig creates a new loadpoint
func (*Loadpoint) ActivePhases ¶
ActivePhases returns the number of expectedly active phases for the meter. If unknown for 1p3p chargers during startup it will assume 3p.
func (*Loadpoint) EffectiveMaxPower ¶
EffectiveMaxPower returns the effective max power taking vehicle capabilities and phase scaling into account
func (*Loadpoint) EffectiveMinPower ¶
EffectiveMinPower returns the effective min power for the minimum active phases
func (*Loadpoint) EffectivePlanId ¶
EffectivePlanSoc returns the id for the current plan
func (*Loadpoint) EffectivePlanSoc ¶
EffectivePlanSoc returns the soc target for the current plan
func (*Loadpoint) EffectivePlanTime ¶
EffectivePlanTime returns the effective plan time
func (*Loadpoint) EffectivePriority ¶
EffectivePriority returns the effective priority
func (*Loadpoint) GetBatteryBoost ¶
GetBatteryBoost returns the battery boost
func (*Loadpoint) GetChargePower ¶
GetChargePower returns the current charge power
func (*Loadpoint) GetChargePowerFlexibility ¶
GetChargePowerFlexibility returns the flexible amount of current charging power
func (*Loadpoint) GetCircuit ¶
GetCircuit returns the assigned circuit
func (*Loadpoint) GetDisableDelay ¶
GetDisableDelay gets the loadpoint enable delay
func (*Loadpoint) GetDisableThreshold ¶
GetDisableThreshold gets the loadpoint enable threshold
func (*Loadpoint) GetEnableDelay ¶
GetEnableDelay gets the loadpoint enable delay
func (*Loadpoint) GetEnableThreshold ¶
GetEnableThreshold gets the loadpoint enable threshold
func (*Loadpoint) GetLimitEnergy ¶
GetLimitEnergy returns the session limit energy
func (*Loadpoint) GetLimitSoc ¶
GetLimitSoc returns the session limit soc
func (*Loadpoint) GetMaxCurrent ¶
GetMaxCurrent returns the max loadpoint current
func (*Loadpoint) GetMaxPhaseCurrent ¶
GetMaxPhaseCurrent returns the current charge power
func (*Loadpoint) GetMaxPower ¶
GetMaxPower returns the max loadpoint power taking vehicle capabilities and phase scaling into account
func (*Loadpoint) GetMinCurrent ¶
GetMinCurrent returns the min loadpoint current
func (*Loadpoint) GetMinPower ¶
GetMinPower returns the min loadpoint power for a single phase
func (*Loadpoint) GetMode ¶
func (lp *Loadpoint) GetMode() api.ChargeMode
GetMode returns loadpoint charge mode
func (*Loadpoint) GetPlan ¶
func (lp *Loadpoint) GetPlan(targetTime time.Time, requiredDuration time.Duration) (api.Rates, error)
GetPlan creates a charging plan for given time and duration
func (*Loadpoint) GetPlanEnergy ¶
GetPlanEnergy returns plan target energy
func (*Loadpoint) GetPlanGoal ¶
GetPlanGoal returns the plan goal in %, true or kWh, false
func (*Loadpoint) GetPlanRequiredDuration ¶
GetPlanRequiredDuration is the estimated total charging duration
func (*Loadpoint) GetPriority ¶
GetPriority returns the loadpoint priority
func (*Loadpoint) GetRemainingDuration ¶
GetRemainingDuration is the estimated remaining charging duration
func (*Loadpoint) GetRemainingEnergy ¶
GetRemainingEnergy is the remaining charge energy in Wh
func (*Loadpoint) GetSmartCostLimit ¶
GetSmartCostLimit gets the smart cost limit
func (*Loadpoint) GetStatus ¶
func (lp *Loadpoint) GetStatus() api.ChargeStatus
GetStatus returns the charging status
func (*Loadpoint) GetVehicle ¶
GetVehicle gets the active vehicle
func (*Loadpoint) HasChargeMeter ¶
HasChargeMeter determines if a physical charge meter is attached
func (*Loadpoint) IsFastChargingActive ¶
IsFastChargingActive indicates if fast charging with maximum power is active
func (*Loadpoint) Prepare ¶
func (lp *Loadpoint) Prepare(uiChan chan<- util.Param, pushChan chan<- push.Event, lpChan chan<- *Loadpoint)
Prepare loadpoint configuration by adding missing helper elements
func (*Loadpoint) PublishEffectiveValues ¶
func (lp *Loadpoint) PublishEffectiveValues()
PublishEffectiveValues publishes all effective values
func (*Loadpoint) RemoteControl ¶
func (lp *Loadpoint) RemoteControl(source string, demand loadpoint.RemoteDemand)
RemoteControl sets remote status demand
func (*Loadpoint) SetBatteryBoost ¶
SetBatteryBoost sets the battery boost
func (*Loadpoint) SetDisableDelay ¶
SetDisableDelay sets loadpoint disable delay
func (*Loadpoint) SetDisableThreshold ¶
SetDisableThreshold sets loadpoint disable threshold
func (*Loadpoint) SetEnableDelay ¶
SetEnableDelay sets loadpoint enable delay
func (*Loadpoint) SetEnableThreshold ¶
SetEnableThreshold sets loadpoint enable threshold
func (*Loadpoint) SetLimitEnergy ¶
SetLimitEnergy sets the session energy limit
func (*Loadpoint) SetLimitSoc ¶
SetLimitSoc sets the session soc limit
func (*Loadpoint) SetMaxCurrent ¶
SetMaxCurrent sets the max loadpoint current
func (*Loadpoint) SetMinCurrent ¶
SetMinCurrent sets the min loadpoint current
func (*Loadpoint) SetMode ¶
func (lp *Loadpoint) SetMode(mode api.ChargeMode)
SetMode sets loadpoint charge mode
func (*Loadpoint) SetPlanEnergy ¶
SetPlanEnergy sets plan target energy
func (*Loadpoint) SetPriority ¶
SetPriority sets the loadpoint priority
func (*Loadpoint) SetRemainingDuration ¶
SetRemainingDuration sets the estimated remaining charging duration
func (*Loadpoint) SetRemainingEnergy ¶
SetRemainingEnergy sets the remaining charge energy in Wh
func (*Loadpoint) SetSmartCostLimit ¶
SetSmartCostLimit sets the smart cost limit
func (*Loadpoint) SetVehicle ¶
SetVehicle sets the active vehicle
func (*Loadpoint) SocBasedPlanning ¶
SocBasedPlanning returns true if soc based planning is enabled
func (*Loadpoint) StartVehicleDetection ¶
func (lp *Loadpoint) StartVehicleDetection()
StartVehicleDetection allows triggering vehicle detection for debugging purposes
func (*Loadpoint) Update ¶
func (lp *Loadpoint) Update(sitePower, batteryBoostPower float64, rates api.Rates, batteryBuffered, batteryStart bool, greenShare float64, effPrice, effCo2 *float64)
Update is the main control function. It reevaluates meters and charger state
func (*Loadpoint) UpdateChargePowerAndCurrents ¶
UpdateChargePowerAndCurrents updates charge meter power and currents for load management
type MetersConfig ¶
type MetersConfig struct { GridMeterRef string `mapstructure:"grid"` // Grid usage meter PVMetersRef []string `mapstructure:"pv"` // PV meter BatteryMetersRef []string `mapstructure:"battery"` // Battery charging meter ExtMetersRef []string `mapstructure:"ext"` // Meters used only for monitoring AuxMetersRef []string `mapstructure:"aux"` // Auxiliary meters }
MetersConfig contains the site's meter configuration
type PollConfig ¶
type PollConfig struct { Mode string `mapstructure:"mode"` // polling mode charging (default), connected, always Interval time.Duration `mapstructure:"interval"` // interval when not charging }
PollConfig defines the vehicle polling mode and interval
type Progress ¶
type Progress struct {
// contains filtered or unexported fields
}
func NewProgress ¶
type Site ¶
type Site struct { *Health sync.RWMutex // configuration Title string `mapstructure:"title"` // UI title Voltage float64 `mapstructure:"voltage"` // Operating voltage. 230V for Germany. ResidualPower float64 `mapstructure:"residualPower"` // PV meter only: household usage. Grid meter: household safety margin Meters MetersConfig `mapstructure:"meters"` // Meter references // TODO deprecated CircuitRef_ string `mapstructure:"circuit"` // Circuit reference MaxGridSupplyWhileBatteryCharging_ float64 `mapstructure:"maxGridSupplyWhileBatteryCharging"` // ignore battery charging if AC consumption is above this value // contains filtered or unexported fields }
Site is the main configuration container. A site can host multiple loadpoints.
func NewSiteFromConfig ¶
NewSiteFromConfig creates a new site
func (*Site) GetAuxMeterRefs ¶
GetAuxMeterRefs returns the AuxMeterRef
func (*Site) GetBatteryDischargeControl ¶
GetBatteryDischargeControl returns the battery control mode (no discharge only)
func (*Site) GetBatteryGridChargeLimit ¶
func (*Site) GetBatteryMeterRefs ¶
GetBatteryMeterRefs returns the BatteryMeterRef
func (*Site) GetBatteryMode ¶
func (site *Site) GetBatteryMode() api.BatteryMode
GetBatteryMode returns the battery mode
func (*Site) GetBufferSoc ¶
GetBufferSoc returns the BufferSoc
func (*Site) GetBufferStartSoc ¶
GetBufferStartSoc returns the BufferStartSoc
func (*Site) GetCircuit ¶
GetCircuit returns the root circuit
func (*Site) GetGridMeterRef ¶
GetGridMeterRef returns the GridMeterRef
func (*Site) GetPVMeterRefs ¶
GetPVMeterRefs returns the PvMeterRef
func (*Site) GetPrioritySoc ¶
GetPrioritySoc returns the PrioritySoc
func (*Site) GetResidualPower ¶
GetResidualPower returns the ResidualPower
func (*Site) Loadpoints ¶
Loadpoints returns the loadpoints as api interfaces
func (*Site) Run ¶
Run is the main control loop. It reacts to trigger events by updating measurements and executing control logic.
func (*Site) SetAuxMeterRefs ¶
SetAuxMeterRefs sets the AuxMeterRef
func (*Site) SetBatteryDischargeControl ¶
SetBatteryDischargeControl sets the battery control mode (no discharge only)
func (*Site) SetBatteryGridChargeLimit ¶
func (*Site) SetBatteryMeterRefs ¶
SetBatteryMeterRefs sets the BatteryMeterRef
func (*Site) SetBatteryMode ¶
func (site *Site) SetBatteryMode(batMode api.BatteryMode)
SetBatteryMode sets the battery mode
func (*Site) SetBufferSoc ¶
SetBufferSoc sets the BufferSoc
func (*Site) SetBufferStartSoc ¶
SetBufferStartSoc sets the BufferStartSoc
func (*Site) SetCircuit ¶
SetCircuit sets the root circuit
func (*Site) SetGridMeterRef ¶
SetGridMeterRef sets the GridMeterRef
func (*Site) SetPVMeterRefs ¶
SetPVMeterRefs sets the PvMeterRef
func (*Site) SetPrioritySoc ¶
SetPrioritySoc sets the PrioritySoc
func (*Site) SetResidualPower ¶
SetResidualPower sets the ResidualPower
type SocConfig ¶
type SocConfig struct { Poll PollConfig `mapstructure:"poll"` Estimate *bool `mapstructure:"estimate"` }
SocConfig defines soc settings, estimation and update behavior
type Stats ¶
type Stats struct {
// contains filtered or unexported fields
}
Publishes long term charging statistics
type ThresholdConfig ¶
ThresholdConfig defines enable/disable hysteresis parameters
Source Files ¶
- energy_metrics.go
- health.go
- helper.go
- loadpoint.go
- loadpoint_api.go
- loadpoint_charger.go
- loadpoint_effective.go
- loadpoint_phases.go
- loadpoint_plan.go
- loadpoint_session.go
- loadpoint_smartcost.go
- loadpoint_vehicle.go
- progress.go
- settings.go
- site.go
- site_api.go
- site_battery.go
- site_circuits.go
- site_vehicles.go
- stats.go
- timer.go
Directories ¶
Path | Synopsis |
---|---|
Package loadpoint is a generated GoMock package.
|
Package loadpoint is a generated GoMock package. |
Package vehicle is a generated GoMock package.
|
Package vehicle is a generated GoMock package. |