Skip to content

Commit

Permalink
Add Smartfox (#10253)
Browse files Browse the repository at this point in the history
  • Loading branch information
alaingiller authored Oct 13, 2023
1 parent 51fa490 commit 57a0023
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 3 deletions.
80 changes: 80 additions & 0 deletions templates/definition/meter/smartfox.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
template: smartfox
products:
- brand: Smartfox
description:
generic: Smartfox Reg/Reg extended/Pro/Pro 2/Pro Light/Pro Light 2/Light
requirements:
description:
de: |
Kann verwendet werden, um Daten für 'grid', 'pv' und 'aux' zu erhalten.
Wenn "usage" nicht definiert ist, wird die Leistung für die Warmwasserbereitung zurückgegeben (als "aux" zu verwenden).
en: |
Can be used to get 'grid', 'pv' and 'aux' data.
If 'usage' is not defined, then return the power for the water heating (to be used as 'aux').
params:
- name: usage
choice: ["grid", "pv"]
- name: host
render: |
{{- define "uri" -}}
http://{{ .host }}/all
{{- end }}
type: custom
{{- if not .usage }}
power:
source: http
uri: {{ include "uri" . }}
jq: .power_sf
{{- end }}
{{- if eq .usage "grid" }}
power:
source: http
uri: {{ include "uri" . }}
jq: .power_io
energy:
source: http
uri: {{ include "uri" . }}
jq: .energy_in
scale: 0.001
voltages:
- source: http
uri: {{ include "uri" . }}
jq: .voltages[0]
- source: http
uri: {{ include "uri" . }}
jq: .voltages[1]
- source: http
uri: {{ include "uri" . }}
jq: .voltages[2]
currents:
- source: http
uri: {{ include "uri" . }}
jq: .currents[0]
- source: http
uri: {{ include "uri" . }}
jq: .currents[1]
- source: http
uri: {{ include "uri" . }}
jq: .currents[2]
powers:
- source: http
uri: {{ include "uri" . }}
jq: .powers[0]
- source: http
uri: {{ include "uri" . }}
jq: .powers[1]
- source: http
uri: {{ include "uri" . }}
jq: .powers[2]
{{- end }}
{{- if eq .usage "pv" }}
power:
source: http
uri: {{ include "uri" . }}
jq: .PvPower[0]
energy:
source: http
uri: {{ include "uri" . }}
jq: .PvEnergy[0]
scale: 0.001
{{- end }}
2 changes: 2 additions & 0 deletions templates/evcc.io/brands.json
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@
"Shelly",
"Siemens",
"SMA",
"Smartfox",
"SofarSolar",
"Solaranzeige",
"SolarEdge",
Expand Down Expand Up @@ -173,6 +174,7 @@
"Senergy",
"Shelly",
"SMA",
"Smartfox",
"SofarSolar",
"Solaranzeige",
"SolarEdge",
Expand Down
5 changes: 2 additions & 3 deletions util/templates/generate/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"os"
"path"
"slices"
"sort"
"strings"

"github.com/evcc-io/evcc/util/templates"
Expand Down Expand Up @@ -88,8 +87,8 @@ func clearDir(dir string) error {
}

func sorted(keys []string) []string {
sort.Slice(keys, func(i, j int) bool {
return strings.ToLower(keys[i]) < strings.ToLower(keys[j])
slices.SortFunc(keys, func(i, j string) int {
return strings.Compare(strings.ToLower(i), strings.ToLower(j))
})
return slices.Compact(keys)
}
Expand Down

0 comments on commit 57a0023

Please sign in to comment.