Support Audi and Tesla vehicle APIs (#20)
This commit is contained in:
parent
0a63ceb90a
commit
ef6140cce5
24 changed files with 432 additions and 137 deletions
|
|
@ -55,7 +55,9 @@ type ChargeRater interface {
|
|||
ChargedEnergy() (float64, error)
|
||||
}
|
||||
|
||||
// SoC represents the EV battery's state
|
||||
type SoC interface {
|
||||
// Vehicle represents the EV and it's battery
|
||||
type Vehicle interface {
|
||||
Title() string
|
||||
Capacity() int64
|
||||
ChargeState() (float64, error)
|
||||
}
|
||||
|
|
|
|||
24
api/decoder.go
Normal file
24
api/decoder.go
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
package api
|
||||
|
||||
import (
|
||||
"github.com/mitchellh/mapstructure"
|
||||
)
|
||||
|
||||
// DecodeOther decodes string map into target configuration
|
||||
func DecodeOther(log *Logger, other map[string]interface{}, cc interface{}) {
|
||||
decoderConfig := &mapstructure.DecoderConfig{
|
||||
Result: cc,
|
||||
ErrorUnused: true,
|
||||
WeaklyTypedInput: true,
|
||||
DecodeHook: mapstructure.StringToTimeDurationHookFunc(),
|
||||
}
|
||||
|
||||
decoder, err := mapstructure.NewDecoder(decoderConfig)
|
||||
if err != nil {
|
||||
log.FATAL.Fatal(err)
|
||||
}
|
||||
|
||||
if err := decoder.Decode(other); err != nil {
|
||||
log.FATAL.Fatal(err)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue