diff --git a/go.mod b/go.mod index 021050daa..2c3cd5376 100644 --- a/go.mod +++ b/go.mod @@ -3,10 +3,10 @@ module github.com/andig/evcc go 1.13 require ( + github.com/andig/evcc-config v0.0.0-20200728142959-b798a8b6b384 github.com/asaskevich/EventBus v0.0.0-20200428142821-4fc0642a29f3 github.com/avast/retry-go v2.6.0+incompatible github.com/benbjohnson/clock v1.0.3 - github.com/deepmap/oapi-codegen v1.3.9 // indirect github.com/eclipse/paho.mqtt.golang v1.2.0 github.com/go-telegram-bot-api/telegram-bot-api v4.6.4+incompatible github.com/godbus/dbus/v5 v5.0.3 @@ -16,7 +16,6 @@ require ( github.com/gorilla/websocket v1.4.2 github.com/gregdel/pushover v0.0.0-20200416074932-c8ad547caed4 github.com/grid-x/modbus v0.0.0-20200704184817-73c05928caa1 - github.com/hashicorp/go-version v1.2.1 // indirect github.com/influxdata/influxdb-client-go v1.4.0 github.com/itchyny/gojq v0.11.0 github.com/joeshaw/carwings v0.0.0-20191118152321-61b46581307a @@ -27,21 +26,13 @@ require ( github.com/mjibson/esc v0.2.0 github.com/muka/go-bluetooth v0.0.0-20200619025933-f6113f7141c5 github.com/nirasan/go-oauth-pkce-code-verifier v0.0.0-20170819232839-0fbfe93532da - github.com/pelletier/go-toml v1.8.0 // indirect github.com/pkg/errors v0.9.1 - github.com/sirupsen/logrus v1.6.0 // indirect - github.com/smartystreets/assertions v1.0.0 // indirect - github.com/spf13/afero v1.3.2 // indirect github.com/spf13/cobra v1.0.0 github.com/spf13/jwalterweatherman v1.1.0 github.com/spf13/viper v1.7.0 github.com/tcnksm/go-latest v0.0.0-20170313132115-e3007ae9052e - github.com/technoweenie/multipartstreamer v1.0.1 // indirect github.com/volkszaehler/mbmd v0.0.0-20200717102329-c4d965bd1eac - golang.org/x/crypto v0.0.0-20200709230013-948cd5f35899 // indirect golang.org/x/net v0.0.0-20200707034311-ab3426394381 - golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae // indirect - golang.org/x/text v0.3.3 // indirect golang.org/x/tools v0.0.0-20200717024301-6ddee64345a6 - gopkg.in/ini.v1 v1.57.0 // indirect + gopkg.in/yaml.v3 v3.0.0-20200605160147-a5ece683394c ) diff --git a/go.sum b/go.sum index 3b0bcb2a4..cdeb2613c 100644 --- a/go.sum +++ b/go.sum @@ -19,6 +19,9 @@ github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuy github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= github.com/alvaroloes/enumer v1.1.2 h1:5khqHB33TZy1GWCO/lZwcroBFh7u+0j40T83VUbfAMY= github.com/alvaroloes/enumer v1.1.2/go.mod h1:FxrjvuXoDAx9isTJrv4c+T410zFi0DtXIT0m65DJ+Wo= +github.com/andig/evcc v0.0.0-20200727161511-d58eb15f2dc9/go.mod h1:8HONEC6cC2s4k0u3QL7GIjrYOZYTOKiiXybw0FIJL0A= +github.com/andig/evcc-config v0.0.0-20200728142959-b798a8b6b384 h1:ol6wEK2NJCIKjyVk3cyQsVKsi1QaVm77XlMNKTLidQA= +github.com/andig/evcc-config v0.0.0-20200728142959-b798a8b6b384/go.mod h1:N0hIjIy+5E2AR1fF7Tg2IzBlblBrnFvCCaDGAaHzbWk= github.com/andig/gosunspec v0.0.0-20200429133549-3cf6a82fed9c h1:AMtX56iHlNYVxMID7fe9efuVtaxgtdjyMeolg7q87IE= github.com/andig/gosunspec v0.0.0-20200429133549-3cf6a82fed9c/go.mod h1:YkshK8WMzYn1iXAZzHUO75gIqhMSan2ctgBVtBkRIyA= github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o= @@ -526,6 +529,7 @@ gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU= gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v3 v3.0.0-20200605160147-a5ece683394c h1:grhR+C34yXImVGp7EzNk+DTIk+323eIUWOmEevy6bDo= gopkg.in/yaml.v3 v3.0.0-20200605160147-a5ece683394c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= diff --git a/meter/config_test.go b/meter/config_test.go new file mode 100644 index 000000000..c27b6a87c --- /dev/null +++ b/meter/config_test.go @@ -0,0 +1,36 @@ +package meter + +import ( + "testing" + + "github.com/andig/evcc-config/registry" + _ "github.com/andig/evcc-config/templates" + "github.com/andig/evcc/util" + "gopkg.in/yaml.v3" +) + +func TemplatesByClass(class string) []registry.Template { + templates := make([]registry.Template, 0) + for _, t := range registry.Registry { + if t.Class == class { + templates = append(templates, t) + } + } + return templates +} + +func TestMeters(t *testing.T) { + log := util.NewLogger("foo") + templates := TemplatesByClass("meter") + + for _, tmpl := range templates { + t.Logf("%s: %s", tmpl.Class, tmpl.Name) + + var conf map[string]interface{} + if err := yaml.Unmarshal([]byte(tmpl.Sample), &conf); err != nil { + t.Error(err) + } + + _ = NewFromConfig(log, tmpl.Type, conf) + } +}