Skip to content

Commit

Permalink
Easee: add RFID identification (#2292)
Browse files Browse the repository at this point in the history
  • Loading branch information
andig committed Apr 7, 2022
1 parent ad836be commit 167772d
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion charger/easee.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ type Easee struct {
phaseMode int
currentPower, sessionEnergy,
currentL1, currentL2, currentL3 float64
rfid string
}

func init() {
Expand Down Expand Up @@ -247,6 +248,8 @@ func (c *Easee) observe(typ string, i json.RawMessage) {
c.log.ERROR.Println(err)
return
}
case easee.String:
value = res.Value
}

c.mux.L.Lock()
Expand All @@ -261,6 +264,8 @@ func (c *Easee) observe(typ string, i json.RawMessage) {
c.updated = time.Now()

switch res.ID {
case easee.USER_IDTOKEN:
c.rfid = res.Value
case easee.IS_ENABLED:
c.chargerEnabled = value.(bool)
case easee.TOTAL_POWER:
Expand Down Expand Up @@ -303,7 +308,7 @@ func (c *Easee) observe(typ string, i json.RawMessage) {
value.(int) == easee.ModeReadyToCharge
}

c.log.TRACE.Printf("%s %s: %s %.4v", typ, res.Mid, res.ID, value)
c.log.TRACE.Printf("%s %s: %s %v", typ, res.Mid, res.ID, value)
}

// ProductUpdate implements the signalr receiver
Expand Down Expand Up @@ -484,3 +489,13 @@ func (c *Easee) Currents() (float64, float64, float64, error) {

return c.currentL1, c.currentL2, c.currentL3, nil
}

var _ api.Identifier = (*Easee)(nil)

// Currents implements the api.MeterCurrent interface
func (c *Easee) Identify() (string, error) {
c.mux.L.Lock()
defer c.mux.L.Unlock()

return c.rfid, nil
}

0 comments on commit 167772d

Please sign in to comment.