https://github.com/ChargePi/ocpp-manager
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.
https://github.com/ChargePi/ocpp-manager
charge-point emobility ocpp ocpp16j
Last synced: 11 months ago
JSON representation
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.
- Host: GitHub
- URL: https://github.com/ChargePi/ocpp-manager
- Owner: ChargePi
- License: mit
- Created: 2022-01-02T21:00:32.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2025-07-07T20:30:55.000Z (11 months ago)
- Last Synced: 2025-07-07T23:25:40.151Z (11 months ago)
- Topics: charge-point, emobility, ocpp, ocpp16j
- Language: Go
- Homepage:
- Size: 96.7 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.md
- Code of conduct: CODE_OF_CONDUCT.md
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
- awesome-ev-charging - ChargePi/ocpp-manager
README
# 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
- [x] Configuration versioning
- [x] Custom value validation
- [x] Mandatory key enforcement
- [x] Support for OCPP 1.6
- [ ] Support for OCPP 2.0.1
## Installing
```bash
go get github.com/ChargePi/ocpp-manager@latest
```
## ⚡ Usage
Check out the full [OCPP 1.6 example](examples/v16/example.go).
```go
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"
)
func main() {
log.SetLevel(log.DebugLevel)
supportedProfiles := []string{core.ProfileName, smartcharging.ProfileName}
defaultConfig, err := ocpp_v16.DefaultConfiguration(supportedProfiles...)
if err != nil {
log.Errorf("Error getting default configuration: %v", err)
return
}
manager, err := ocpp_v16.NewV16ConfigurationManager(defaultConfig, supportedProfiles...)
// Get value
value, err := manager.GetConfigurationValue(ocpp_v16.AuthorizeRemoteTxRequests)
if err != nil {
log.Errorf("Error getting configuration value: %v", err)
return
}
log.Println(*value)
// Update key
val := "false"
err = manager.UpdateKey(ocpp_v16.AuthorizeRemoteTxRequests, &val)
if err != nil {
log.Errorf("Error updating key: %v", err)
return
}
// Get value
value, err = manager.GetConfigurationValue(ocpp_v16.AuthorizeRemoteTxRequests)
if err != nil {
log.Errorf("Error getting configuration value: %v", err)
return
}
log.Println(*value)
// Register custom key validator, which will prevent the key from being updated
manager.RegisterCustomKeyValidator(func(key ocpp_v16.Key, value *string) bool {
return key != ocpp_v16.AuthorizeRemoteTxRequests
})
// Update key
val = "true"
err = manager.UpdateKey(ocpp_v16.AuthorizeRemoteTxRequests, &val)
if err != 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](LICENSE.md) file for details.
## Contributing
Please read [CONTRIBUTING.md](CONTRIBUTING.md) for details on our code of conduct, and the process for submitting pull
requests to us.