chore: simplify

This commit is contained in:
andig 2023-11-18 10:28:55 +01:00
parent 2e15a47cee
commit eb98e080a8
3 changed files with 9 additions and 15 deletions

View file

@ -11,11 +11,9 @@ func init() {
func NewChargerFromTemplateConfig(other map[string]interface{}) (api.Charger, error) {
instance, err := templates.RenderInstance(templates.Charger, other)
var res api.Charger
if err == nil {
res, err = NewFromConfig(instance.Type, instance.Other)
if err != nil {
return nil, err
}
return res, err
return NewFromConfig(instance.Type, instance.Other)
}

View file

@ -11,11 +11,9 @@ func init() {
func NewMeterFromTemplateConfig(other map[string]interface{}) (api.Meter, error) {
instance, err := templates.RenderInstance(templates.Meter, other)
var res api.Meter
if err == nil {
res, err = NewFromConfig(instance.Type, instance.Other)
if err != nil {
return nil, err
}
return res, err
return NewFromConfig(instance.Type, instance.Other)
}

View file

@ -11,11 +11,9 @@ func init() {
func NewVehicleFromTemplateConfig(other map[string]interface{}) (api.Vehicle, error) {
instance, err := templates.RenderInstance(templates.Vehicle, other)
var res api.Vehicle
if err == nil {
res, err = NewFromConfig(instance.Type, instance.Other)
if err != nil {
return nil, err
}
return res, err
return NewFromConfig(instance.Type, instance.Other)
}