* Migrate EEBUS to enbility/eebus-go - adopt enbility/eebus-go library - fully compatible with existing EEBUS setup - centralize EEBUS certificate generation for configure and certificate creation cmds - automatically utilizes native avahi mDNS setup if installed, which does not have missing IP issues as zeroconf library - mDNS discovery and announcement is fully handled by the library - improved double connection and reconnection handling over previous library - logging now fully supported evcc log levels - tested with Elli Connect and Porsche Mobile Charger Connect
56 lines
1.1 KiB
Go
56 lines
1.1 KiB
Go
package cmd
|
|
|
|
import (
|
|
"os"
|
|
"text/template"
|
|
|
|
"github.com/Masterminds/sprig/v3"
|
|
"github.com/evcc-io/evcc/server"
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
// teslaCmd represents the vehicle command
|
|
var eebusCmd = &cobra.Command{
|
|
Use: "eebus-cert",
|
|
Short: "Generate EEBUS certificate for using EEBUS compatible chargers",
|
|
Run: runEEBUSCert,
|
|
}
|
|
|
|
func init() {
|
|
rootCmd.AddCommand(eebusCmd)
|
|
}
|
|
|
|
const tmpl = `
|
|
Add the following to the evcc config file:
|
|
|
|
eebus:
|
|
certificate:
|
|
public: |
|
|
{{ .public | indent 6 }}
|
|
private: |
|
|
{{ .private | indent 6 }}
|
|
`
|
|
|
|
func generateEEBUSCert() {
|
|
cert, err := server.CreateEEBUSCertificate()
|
|
if err != nil {
|
|
log.FATAL.Fatal("could not create certificate", err)
|
|
}
|
|
|
|
pubKey, privKey, err := server.GetX509KeyPair(cert)
|
|
if err != nil {
|
|
log.FATAL.Fatal("could not process generated certificate", err)
|
|
}
|
|
|
|
t := template.Must(template.New("out").Funcs(template.FuncMap(sprig.FuncMap())).Parse(tmpl))
|
|
if err := t.Execute(os.Stdout, map[string]interface{}{
|
|
"public": pubKey,
|
|
"private": privKey,
|
|
}); err != nil {
|
|
log.FATAL.Fatal("rendering failed", err)
|
|
}
|
|
}
|
|
|
|
func runEEBUSCert(cmd *cobra.Command, args []string) {
|
|
generateEEBUSCert()
|
|
}
|