Skip to content

Commit 4dcd8a2

Browse files
authored
Notify consumer about charging profile update when a transaction stops (#788)
* Executing signal_set_charging_profiles_callback when a transaction is stopped to notify the consumer. The stopped transaction might have removed previously reported TxProfiles (as part of the composite schedule) which could influence the load balancing / charging power of the EVSEs. * Added signal of profiles when clearing profiles. * Only signal if profiles changed --------- Signed-off-by: pietfried <[email protected]>
1 parent 8124039 commit 4dcd8a2

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

lib/ocpp/v16/charge_point_impl.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2340,6 +2340,11 @@ void ChargePointImpl::handleClearChargingProfileRequest(ocpp::Call<ClearCharging
23402340

23412341
ocpp::CallResult<ClearChargingProfileResponse> call_result(response, call.uniqueId);
23422342
this->send<ClearChargingProfileResponse>(call_result);
2343+
2344+
if (response.status == ClearChargingProfileStatus::Accepted and
2345+
this->signal_set_charging_profiles_callback != nullptr) {
2346+
this->signal_set_charging_profiles_callback();
2347+
}
23432348
}
23442349

23452350
void ChargePointImpl::handleTriggerMessageRequest(ocpp::Call<TriggerMessageRequest> call) {
@@ -4096,9 +4101,12 @@ void ChargePointImpl::on_transaction_stopped(const int32_t connector, const std:
40964101
this->status->submit_event(connector, FSMEvent::TransactionStoppedAndUserActionRequired, ocpp::DateTime());
40974102
this->stop_transaction(connector, reason, id_tag_end);
40984103
this->transaction_handler->remove_active_transaction(connector);
4099-
this->smart_charging_handler->clear_all_profiles_with_filter(std::nullopt, connector, std::nullopt,
4100-
ChargingProfilePurposeType::TxProfile, false);
41014104

4105+
const auto profile_cleared = this->smart_charging_handler->clear_all_profiles_with_filter(
4106+
std::nullopt, connector, std::nullopt, ChargingProfilePurposeType::TxProfile, false);
4107+
if (profile_cleared and this->signal_set_charging_profiles_callback != nullptr) {
4108+
this->signal_set_charging_profiles_callback();
4109+
}
41024110
reset_pricing_triggers(connector);
41034111
}
41044112

0 commit comments

Comments
 (0)