@@ -356,9 +356,23 @@ bool SmartChargingManager::handleMessage(const ocpp::messages::GetCompositeSched
356356 (void )error_code;
357357 (void )error_message;
358358
359+ ocpp::types::ChargingRateUnitType charging_rate_unit;
360+ if (!request.chargingRateUnit .isSet ())
361+ {
362+ if (m_ocpp_config.chargingScheduleAllowedChargingRateUnit ().find (" Power" ) != std::string::npos)
363+ {
364+ charging_rate_unit = types::ChargingRateUnitType::W;
365+ } else
366+ {
367+ charging_rate_unit = types::ChargingRateUnitType::A;
368+ }
369+ } else {
370+ charging_rate_unit = request.chargingRateUnit .value ();
371+ }
372+
359373 LOG_INFO << " GetCompositeSchedule requested : connectorId = " << request.connectorId << " - duration = " << request.duration
360- << " - chargingRateUnit = "
361- << (request.chargingRateUnit .isSet () ? ChargingRateUnitTypeHelper. toString (request. chargingRateUnit ) : " not set " );
374+ << " - chargingRateUnit = " << ChargingRateUnitTypeHelper. toString (charging_rate_unit)
375+ << (! request.chargingRateUnit .isSet () ? " (from allowed charging unit) " : " " );
362376
363377 // Lock profiles
364378 std::lock_guard<std::mutex> lock (m_mutex);
@@ -442,14 +456,8 @@ bool SmartChargingManager::handleMessage(const ocpp::messages::GetCompositeSched
442456
443457 ChargingSchedule& schedule = response.chargingSchedule .value ();
444458 schedule.duration = 0 ;
445- if (request.chargingRateUnit .isSet ())
446- {
447- schedule.chargingRateUnit = request.chargingRateUnit ;
448- }
449- else
450- {
451- schedule.chargingRateUnit = ChargingRateUnitType::A;
452- }
459+ schedule.chargingRateUnit = charging_rate_unit;
460+
453461 // Adjust start if needed since first period must start at 0
454462 time_t offset = periods[0 ].start ;
455463 schedule.startSchedule = DateTime (now.timestamp () + offset);
0 commit comments