From 57a0023c498b664fdb09bcf047ede50486443e6f Mon Sep 17 00:00:00 2001 From: alaingiller Date: Fri, 13 Oct 2023 16:54:04 +0200 Subject: [PATCH] Add Smartfox (#10253) --- templates/definition/meter/smartfox.yaml | 80 ++++++++++++++++++++++++ templates/evcc.io/brands.json | 2 + util/templates/generate/main.go | 5 +- 3 files changed, 84 insertions(+), 3 deletions(-) create mode 100644 templates/definition/meter/smartfox.yaml diff --git a/templates/definition/meter/smartfox.yaml b/templates/definition/meter/smartfox.yaml new file mode 100644 index 0000000000..287dcdfb04 --- /dev/null +++ b/templates/definition/meter/smartfox.yaml @@ -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 }} diff --git a/templates/evcc.io/brands.json b/templates/evcc.io/brands.json index bbcfb9d101..7cc19fab8c 100644 --- a/templates/evcc.io/brands.json +++ b/templates/evcc.io/brands.json @@ -122,6 +122,7 @@ "Shelly", "Siemens", "SMA", + "Smartfox", "SofarSolar", "Solaranzeige", "SolarEdge", @@ -173,6 +174,7 @@ "Senergy", "Shelly", "SMA", + "Smartfox", "SofarSolar", "Solaranzeige", "SolarEdge", diff --git a/util/templates/generate/main.go b/util/templates/generate/main.go index 994970386e..15934bc496 100644 --- a/util/templates/generate/main.go +++ b/util/templates/generate/main.go @@ -6,7 +6,6 @@ import ( "os" "path" "slices" - "sort" "strings" "github.com/evcc-io/evcc/util/templates" @@ -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) }