Skip to content

Commit

Permalink
Merge branch 'master' into device/ocpp-new-templates
Browse files Browse the repository at this point in the history
  • Loading branch information
naltatis authored Aug 9, 2024
2 parents 98c8a62 + ee2284a commit 23f6cfd
Show file tree
Hide file tree
Showing 41 changed files with 1,125 additions and 1,174 deletions.
2 changes: 1 addition & 1 deletion assets/js/components/Config/YamlEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export default {
},
beforeMount() {
loader.config({
paths: { vs: "https://cdn.jsdelivr.net/npm/monaco-editor@0.45.0/min/vs" },
paths: { vs: "https://cdn.jsdelivr.net/npm/monaco-editor@0.50.0/min/vs" },
});
loader.init();
},
Expand Down
7 changes: 3 additions & 4 deletions charger/easee.go
Original file line number Diff line number Diff line change
Expand Up @@ -781,7 +781,7 @@ func (c *Easee) Phases1p3p(phases int) error {
} else {
// charger level
if phases == 3 {
phases = 2 // mode 2 means 3p
phases = 2 // mode 2 means auto
}

// change phaseMode only if necessary
Expand All @@ -795,10 +795,9 @@ func (c *Easee) Phases1p3p(phases int) error {
if _, err = c.postJSONAndWait(uri, data); err != nil {
return err
}

// disable charger to activate changed settings (loadpoint will reenable it)
err = c.Enable(false)
}
// disable charger to activate changed settings (loadpoint will reenable it)
err = c.Enable(false)
}

return err
Expand Down
46 changes: 30 additions & 16 deletions charger/eebus.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ type EEBus struct {
vasVW bool // wether the EVSE supports VW VAS with ISO15118-2

expectedEnableUnpluggedState bool
reconnect bool
current float64

currentLimit float64
Expand Down Expand Up @@ -110,13 +111,6 @@ func NewEEBus(ski string, hasMeter, hasChargedEnergy, vasVW bool) (api.Charger,
return c, nil
}

func (c *EEBus) setEvEntity(entity spineapi.EntityRemoteInterface) {
c.mux.Lock()
defer c.mux.Unlock()

c.ev = entity
}

func (c *EEBus) evEntity() spineapi.EntityRemoteInterface {
c.mux.RLock()
defer c.mux.RUnlock()
Expand All @@ -138,15 +132,18 @@ var _ eebus.Device = (*EEBus)(nil)

// UseCaseEvent implements the eebus.Device interface
func (c *EEBus) UseCaseEvent(device spineapi.DeviceRemoteInterface, entity spineapi.EntityRemoteInterface, event eebusapi.EventType) {
switch event {
c.mux.Lock()
defer c.mux.Unlock()

// EV
switch event {
case evcc.EvConnected:
c.log.TRACE.Println("EV Connected")
c.setEvEntity(entity)
c.ev = entity
c.reconnect = true
c.currentLimit = -1

case evcc.EvDisconnected:
c.log.TRACE.Println("EV Disconnected")
c.setEvEntity(nil)
c.ev = nil
c.currentLimit = -1
}
}
Expand Down Expand Up @@ -223,11 +220,25 @@ func (c *EEBus) isCharging() bool {
}

// Status implements the api.Charger interface
func (c *EEBus) Status() (api.ChargeStatus, error) {
func (c *EEBus) Status() (res api.ChargeStatus, err error) {
if !c.Connected() {
return api.StatusNone, api.ErrTimeout
}

// re-set current limit after reconnect
defer func() {
if err == nil {
c.mux.Lock()
if c.reconnect {
c.reconnect = false
c.mux.Unlock()
err = c.MaxCurrentMillis(c.current)
} else {
c.mux.Unlock()
}
}
}()

evEntity := c.evEntity()
if !c.uc.EvCC.EVConnected(evEntity) {
c.expectedEnableUnpluggedState = false
Expand Down Expand Up @@ -356,13 +367,13 @@ func (c *EEBus) writeCurrentLimitData(currents []float64) error {

_, maxLimits, _, err := c.uc.OpEV.CurrentLimits(evEntity)
if err != nil {
return errors.New("no limits available")
c.log.DEBUG.Println("no limits from the EVSE are provided:", err)
}

// setup the limit data structure
limits := []ucapi.LoadLimitsPhase{}
for phase, current := range currents {
if phase >= len(maxLimits) || phase >= len(ucapi.PhaseNameMapping) {
if phase >= len(ucapi.PhaseNameMapping) {
continue
}

Expand All @@ -373,7 +384,7 @@ func (c *EEBus) writeCurrentLimitData(currents []float64) error {
}

// if the limit equals to the max allowed, then the obligation limit is actually inactive
if current >= maxLimits[phase] {
if phase < len(maxLimits) && current >= maxLimits[phase] {
limit.IsActive = false
}

Expand Down Expand Up @@ -546,6 +557,9 @@ var _ api.CurrentGetter = (*EEBus)(nil)

// GetMaxCurrent implements the api.CurrentGetter interface
func (c *EEBus) GetMaxCurrent() (float64, error) {
c.mux.RLock()
defer c.mux.RUnlock()

if c.currentLimit == -1 {
return 0, api.ErrNotAvailable
}
Expand Down
14 changes: 7 additions & 7 deletions charger/ocpp.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,13 @@ func NewOCPPFromConfig(other map[string]interface{}) (api.Charger, error) {
Connector int
MeterInterval time.Duration
MeterValues string
ConnectTimeout time.Duration
Timeout time.Duration
BootNotification *bool
GetConfiguration *bool
ChargingRateUnit string
AutoStart bool // deprecated, to be removed
NoStop bool // deprecated, to be removed
ConnectTimeout time.Duration // Initial Timeout
Timeout time.Duration // Message Timeout
BootNotification *bool // TODO deprecated
GetConfiguration *bool // TODO deprecated
ChargingRateUnit string // TODO deprecated
AutoStart bool // TODO deprecated
NoStop bool // TODO deprecated
RemoteStart bool
}{
Connector: 1,
Expand Down
4 changes: 4 additions & 0 deletions charger/ocpp/cp_core.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ func (cp *CP) StatusNotification(request *core.StatusNotificationRequest) (*core
return nil, ErrInvalidRequest
}

if request.ConnectorId == 0 {
return new(core.StatusNotificationConfirmation), nil
}

conn := cp.connectorByID(request.ConnectorId)
if conn == nil {
return nil, ErrInvalidConnector
Expand Down
Loading

0 comments on commit 23f6cfd

Please sign in to comment.