Revert "Easee: wait for opmode to initialise (#11342)"
Some checks failed
Some checks failed
This reverts commit b8871310f2.
This commit is contained in:
parent
7320e73059
commit
7819662ad1
1 changed files with 10 additions and 7 deletions
|
|
@ -45,6 +45,7 @@ type Easee struct {
|
|||
*request.Helper
|
||||
charger string
|
||||
site, circuit int
|
||||
updated time.Time
|
||||
lastEnergyPollTriggered time.Time
|
||||
log *util.Logger
|
||||
mux sync.Mutex
|
||||
|
|
@ -277,6 +278,13 @@ func (c *Easee) ProductUpdate(i json.RawMessage) {
|
|||
c.mux.Lock()
|
||||
defer c.mux.Unlock()
|
||||
|
||||
if c.updated.IsZero() {
|
||||
defer once.Do(func() {
|
||||
close(c.done)
|
||||
})
|
||||
}
|
||||
c.updated = time.Now()
|
||||
|
||||
if prevTime, ok := c.obsTime[res.ID]; ok && prevTime.After(res.Timestamp) {
|
||||
// received observation is outdated, ignoring
|
||||
return
|
||||
|
|
@ -328,7 +336,7 @@ func (c *Easee) ProductUpdate(i json.RawMessage) {
|
|||
c.sessionStartEnergy = nil
|
||||
}
|
||||
|
||||
// OpMode changed to 3/charging. Start ticker for periodic requests to update LIFETIME_ENERGY
|
||||
// OpMode changed TO charging. Start ticker for periodic requests to update LIFETIME_ENERGY
|
||||
if c.opMode != easee.ModeCharging && opMode == easee.ModeCharging {
|
||||
if c.stopTicker == nil {
|
||||
c.stopTicker = make(chan struct{})
|
||||
|
|
@ -347,7 +355,7 @@ func (c *Easee) ProductUpdate(i json.RawMessage) {
|
|||
}
|
||||
}
|
||||
|
||||
// OpMode changed from >1 ("car connected") to 1/disconnected - stop ticker if channel exists
|
||||
// OpMode changed FROM >1 ("car connected") TO 1/disconnected - stop ticker if channel exists
|
||||
// channel may not exist regularly if the car was connected but charging never started
|
||||
if c.opMode != easee.ModeDisconnected && opMode == easee.ModeDisconnected && c.stopTicker != nil {
|
||||
close(c.stopTicker)
|
||||
|
|
@ -363,11 +371,6 @@ func (c *Easee) ProductUpdate(i json.RawMessage) {
|
|||
c.requestLifetimeEnergyUpdate()
|
||||
}
|
||||
|
||||
// startup completed
|
||||
if c.opMode != 0 {
|
||||
once.Do(func() { close(c.done) })
|
||||
}
|
||||
|
||||
c.opMode = opMode
|
||||
|
||||
case easee.REASON_FOR_NO_CURRENT:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue