evcc-io/vehicle/template.go
2023-11-18 10:28:55 +01:00

19 lines
425 B
Go

package vehicle
import (
"github.com/evcc-io/evcc/api"
"github.com/evcc-io/evcc/util/templates"
)
func init() {
registry.Add("template", NewVehicleFromTemplateConfig)
}
func NewVehicleFromTemplateConfig(other map[string]interface{}) (api.Vehicle, error) {
instance, err := templates.RenderInstance(templates.Vehicle, other)
if err != nil {
return nil, err
}
return NewFromConfig(instance.Type, instance.Other)
}