Easee: wait for essential state during boot (#20646)
This commit is contained in:
parent
63c1c91484
commit
8ac4b659d4
1 changed files with 17 additions and 3 deletions
|
|
@ -55,6 +55,7 @@ type Easee struct {
|
|||
smartCharging bool
|
||||
authorize bool
|
||||
enabled bool
|
||||
initialStatePresent bool
|
||||
opMode int
|
||||
pilotMode string
|
||||
reasonForNoCurrent int
|
||||
|
|
@ -334,9 +335,6 @@ func (c *Easee) ProductUpdate(i json.RawMessage) {
|
|||
|
||||
c.opMode = opMode
|
||||
|
||||
// startup completed
|
||||
c.startDone()
|
||||
|
||||
case easee.REASON_FOR_NO_CURRENT:
|
||||
c.reasonForNoCurrent = value.(int)
|
||||
case easee.PILOT_MODE:
|
||||
|
|
@ -347,6 +345,22 @@ func (c *Easee) ProductUpdate(i json.RawMessage) {
|
|||
case c.obsC <- res:
|
||||
default:
|
||||
}
|
||||
|
||||
if !c.initialStatePresent && c.checkInitialStatePresent() {
|
||||
// startup completed
|
||||
c.initialStatePresent = true
|
||||
c.startDone()
|
||||
}
|
||||
}
|
||||
|
||||
// check c.obsTime for presence of ALL of the following keys: easee.SESSION_ENERGY, easee.LIFETIME_ENERGY, easee.CHARGER_OP_MODE
|
||||
func (c *Easee) checkInitialStatePresent() bool {
|
||||
for _, key := range []easee.ObservationID{easee.SESSION_ENERGY, easee.LIFETIME_ENERGY, easee.CHARGER_OP_MODE, easee.TOTAL_POWER} {
|
||||
if _, exists := c.obsTime[key]; !exists {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
// ChargerUpdate implements the signalr receiver
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue