Skip to content

Commit

Permalink
Vehicles: collect common properties in includeable template (evcc-io#…
Browse files Browse the repository at this point in the history
  • Loading branch information
andig authored Jun 8, 2024
1 parent 86f2502 commit 62a1e22
Show file tree
Hide file tree
Showing 10 changed files with 29 additions and 60 deletions.
6 changes: 1 addition & 5 deletions templates/definition/vehicle/citroen.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,9 @@ params:
- preset: vehicle-identify
render: |
type: citroen
title: {{ .title }}
icon: {{ .icon }}
{{ include "vehicle-common" . }}
user: {{ .user }}
tokens:
access: {{ .accessToken }}
refresh: {{ .refreshToken }}
capacity: {{ .capacity }}
phases: {{ .phases }}
vin: {{ .vin }}
{{ include "vehicle-identify" . }}
6 changes: 1 addition & 5 deletions templates/definition/vehicle/ds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,9 @@ params:
- preset: vehicle-identify
render: |
type: ds
title: {{ .title }}
icon: {{ .icon }}
{{ include "vehicle-common" . }}
user: {{ .user }}
tokens:
access: {{ .accessToken }}
refresh: {{ .refreshToken }}
capacity: {{ .capacity }}
phases: {{ .phases }}
vin: {{ .vin }}
{{ include "vehicle-identify" . }}
4 changes: 1 addition & 3 deletions templates/definition/vehicle/ford-connect.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,11 @@ params:
- preset: vehicle-identify
render: |
type: ford-connect
{{ include "vehicle-common" . }}
credentials:
id: {{ .clientid }}
secret: {{ .clientsecret }}
tokens:
access: {{ .accessToken }}
refresh: {{ .refreshToken }}
vin: {{ .vin }}
capacity: {{ .capacity }}
phases: {{ .phases }}
{{ include "vehicle-identify" . }}
6 changes: 1 addition & 5 deletions templates/definition/vehicle/mercedes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,9 @@ params:
- preset: vehicle-identify
render: |
type: mercedes
title: {{ .title }}
icon: {{ .icon }}
{{ include "vehicle-common" . }}
user: {{ .user }}
tokens:
access: {{ .accessToken }}
refresh: {{ .refreshToken }}
capacity: {{ .capacity }}
phases: {{ .phases }}
vin: {{ .vin }}
{{ include "vehicle-identify" . }}
6 changes: 1 addition & 5 deletions templates/definition/vehicle/opel.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,9 @@ params:
- preset: vehicle-identify
render: |
type: opel
title: {{ .title }}
icon: {{ .icon }}
{{ include "vehicle-common" . }}
user: {{ .user }}
tokens:
access: {{ .accessToken }}
refresh: {{ .refreshToken }}
capacity: {{ .capacity }}
phases: {{ .phases }}
vin: {{ .vin }}
{{ include "vehicle-identify" . }}
6 changes: 1 addition & 5 deletions templates/definition/vehicle/peugeot.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,9 @@ params:
- preset: vehicle-identify
render: |
type: peugeot
title: {{ .title }}
icon: {{ .icon }}
{{ include "vehicle-common" . }}
user: {{ .user }}
tokens:
access: {{ .accessToken }}
refresh: {{ .refreshToken }}
capacity: {{ .capacity }}
phases: {{ .phases }}
vin: {{ .vin }}
{{ include "vehicle-identify" . }}
6 changes: 1 addition & 5 deletions templates/definition/vehicle/tesla.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,9 @@ params:
- preset: vehicle-identify
render: |
type: tesla
title: {{ .title }}
icon: {{ .icon }}
{{ include "vehicle-common" . }}
tokens:
access: {{ .accessToken }}
refresh: {{ .refreshToken }}
capacity: {{ .capacity }}
phases: {{ .phases }}
vin: {{ .vin }}
{{ include "vehicle-identify" . }}
features: ["coarsecurrent"]
10 changes: 1 addition & 9 deletions templates/definition/vehicle/tronity.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,8 @@ params:
- preset: vehicle-identify
render: |
type: tronity
{{- if .title }}
title: {{ .title }}
{{- end }}
{{- if .icon }}
icon: {{ .icon }}
{{- end }}
{{ include "vehicle-common" . }}
credentials:
id: {{ .clientid }}
secret: {{ .clientsecret }}
vin: {{ .vin }}
capacity: {{ .capacity }}
phases: {{ .phases }}
{{ include "vehicle-identify" . }}
19 changes: 1 addition & 18 deletions util/templates/includes/vehicle-base.tpl
Original file line number Diff line number Diff line change
@@ -1,22 +1,5 @@
{{ define "vehicle-base" }}
{{- if .title }}
title: {{ .title }}
{{- end }}
{{- if .icon }}
icon: {{ .icon }}
{{- end }}
user: {{ .user }}
password: {{ .password }}
{{- if .capacity }}
capacity: {{ .capacity }}
{{- end }}
{{- if .vin }}
vin: {{ .vin }}
{{- end }}
{{- if .phases }}
phases: {{ .phases }}
{{- end }}
{{- if .cache }}
cache: {{ .cache }}
{{- end }}
{{ template "vehicle-common" . }}
{{- end }}
20 changes: 20 additions & 0 deletions util/templates/includes/vehicle-common.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{{ define "vehicle-common" }}
{{- if .title }}
title: {{ .title }}
{{- end }}
{{- if .icon }}
icon: {{ .icon }}
{{- end }}
{{- if .capacity }}
capacity: {{ .capacity }}
{{- end }}
{{- if .vin }}
vin: {{ .vin }}
{{- end }}
{{- if .phases }}
phases: {{ .phases }}
{{- end }}
{{- if .cache }}
cache: {{ .cache }}
{{- end }}
{{- end }}

0 comments on commit 62a1e22

Please sign in to comment.