diff --git a/charger/ocpp.go b/charger/ocpp.go index 73048b263..0739d4944 100644 --- a/charger/ocpp.go +++ b/charger/ocpp.go @@ -1,5 +1,22 @@ package charger +// LICENSE + +// Copyright (c) 2024 premultiply, andig + +// This module is NOT covered by the MIT license. All rights reserved. + +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. + +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + import ( "cmp" "fmt" @@ -11,6 +28,7 @@ import ( "github.com/evcc-io/evcc/charger/ocpp" "github.com/evcc-io/evcc/core/loadpoint" "github.com/evcc-io/evcc/util" + "github.com/evcc-io/evcc/util/sponsor" "github.com/lorenzodonini/ocpp-go/ocpp1.6/core" "github.com/lorenzodonini/ocpp-go/ocpp1.6/types" "github.com/samber/lo" @@ -74,6 +92,10 @@ func NewOCPPFromConfig(other map[string]interface{}) (api.Charger, error) { return c, err } + if !sponsor.IsAuthorized() { + return nil, api.ErrSponsorRequired + } + var ( powerG, totalEnergyG, socG func() (float64, error) currentsG, voltagesG func() (float64, float64, float64, error)