Skip to content

Repository files navigation

OCPP variable manager

A library for managing OCPP variables in Go. It provides a simple way to manage OCPP configuration variables, including getting and setting values, validating values, and enforcing mandatory keys.

Features

  • Configuration versioning
  • Mandatory key enforcement
  • Custom value validation
  • Provides sane default values

Roadmap

  • Configuration versioning
  • Custom value validation
  • Mandatory key enforcement
  • Support for OCPP 1.6
  • Support for OCPP 2.0.1

Installing

 go get github.com/ChargePi/ocpp-manager@latest

⚡ Usage

Check out the full OCPP 1.6 example.

package main
import (
"github.com/ChargePi/ocpp-manager/ocpp_v16""github.com/lorenzodonini/ocpp-go/ocpp1.6/core""github.com/lorenzodonini/ocpp-go/ocpp1.6/smartcharging"
log "github.com/sirupsen/logrus"
)
funcmain() {
log.SetLevel(log.DebugLevel)
supportedProfiles:= []string{core.ProfileName, smartcharging.ProfileName}
defaultConfig, err:=ocpp_v16.DefaultConfiguration(supportedProfiles...)
iferr!=nil {
log.Errorf("Error getting default configuration: %v", err)
return
}
manager, err:=ocpp_v16.NewV16ConfigurationManager(defaultConfig, supportedProfiles...)
// Get valuevalue, err:=manager.GetConfigurationValue(ocpp_v16.AuthorizeRemoteTxRequests)
iferr!=nil {
log.Errorf("Error getting configuration value: %v", err)
return
}
log.Println(*value)
// Update keyval:="false"err=manager.UpdateKey(ocpp_v16.AuthorizeRemoteTxRequests, &val)
iferr!=nil {
log.Errorf("Error updating key: %v", err)
return
}
// Get valuevalue, err=manager.GetConfigurationValue(ocpp_v16.AuthorizeRemoteTxRequests)
iferr!=nil {
log.Errorf("Error getting configuration value: %v", err)
return
}
log.Println(*value)
// Register custom key validator, which will prevent the key from being updatedmanager.RegisterCustomKeyValidator(func(key ocpp_v16.Key, value*string) bool {
returnkey!=ocpp_v16.AuthorizeRemoteTxRequests
})
// Update keyval="true"err=manager.UpdateKey(ocpp_v16.AuthorizeRemoteTxRequests, &val)
iferr!=nil {
log.Errorf("Error updating key: %v", err)
return
}
}

Notes

  1. This library is still in development, and the API might change in the future.
  2. Storing the configuration is not part of this library. You can use a database, a file, or any other storage mechanism to store the configuration by getting the configuration as a map and storing it in your preferred way.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Contributing

Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.

About

Manage your OCPP configuration with ease. A Go library for managing OCPP variables with validation of keys and values, list of keys for different profiles and versioning.

Topics

Resources

Code of conduct

Contributing

Stars

6 stars

Watchers

1 watching

Forks

Releases

Used by

Contributors

Languages