You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

OCPP动态负载均衡:充电会话中设置Charging Profile失败求助

问题:OCPP充电会话中清除Charging Profile后无法设置新配置

我正在使用ocpp-rpc库实现动态负载均衡,遇到核心问题:在进行中的充电会话内,清除原有Charging Profile后无法设置新配置,这直接影响负载均衡逻辑的运行。

想请教:

  1. 充电会话中清除配置后设置新Charging Profile失败的原因是什么?
  2. OCPP标准或ocpp-rpc库中是否有我忽略的细节或限制?

已尝试的操作

  • 初始配置可正常生效:发送RemoteStartTransaction请求时,设置的限制能被充电器正确应用。
    请求示例:
    {"connectorId": 1,"idTag": "remote-116","chargingProfile": {"transactionId": 116,"chargingProfileId": 1,"stackLevel": 1,"chargingProfilePurpose": "TxProfile","chargingProfileKind": "Relative","chargingSchedule": {"chargingRateUnit": "A","chargingSchedulePeriod": [{"startPeriod": 0,"limit": 16}]}}}
    
  • 充电过程中尝试调整配置时,充电器拒绝请求。
    请求示例:
    {"connectorId": 1,"csChargingProfiles": {"chargingProfileId": 1,"transactionId": 154,"stackLevel": 1,"chargingProfilePurpose": "TxProfile","chargingProfileKind": "Absolute","chargingSchedule": {"chargingRateUnit": "A","chargingSchedulePeriod": [{"startPeriod": 0,"limit": 11}]}}}
    
  • 充电开始前,ABB 7.4kw/22kw型号充电器无法接受默认配置请求。
    请求示例:
    {"connectorId": 1,"csChargingProfiles": {"chargingProfileId": 1,"stackLevel": 1,"chargingProfilePurpose": "TxDefaultProfile","chargingProfileKind": "Relative","chargingSchedule": {"chargingRateUnit": "A","chargingSchedulePeriod": [{"startPeriod": 0,"limit": 14}]}}}
    

相关参考(原Github Issue #62翻译内容)

有用户在该Issue中反馈类似问题:使用ocpp-rpc库时,充电会话中更新Charging Profile失败。排查发现,库在处理SetChargingProfile请求时未正确处理transactionId的绑定逻辑;部分充电器(如ABB型号)要求TxProfile必须与当前活跃会话ID严格匹配,且清除原有配置后需等待设备确认完成,才能发送新配置请求。此外,部分充电器对stackLevel优先级处理严格,同一stackLevel下不能存在多个同类型Charging Profile,清除操作需明确指定要删除的chargingProfileId和transactionId,否则设备可能认为原有配置仍生效。


回答

一、OCPP标准层面的限制与细节

  1. TxProfile的会话绑定要求
    OCPP 1.6及2.0标准中,TxProfile类型的Charging Profile必须与**当前活跃充电会话ID(transactionId)**严格绑定。若新请求的transactionId与当前会话ID不匹配或未携带,充电器会直接拒绝。另外,清除原有TxProfile时,必须通过ClearChargingProfile请求明确指定transactionId和chargingProfileId,否则设备可能未彻底清除原有配置,导致新配置因冲突被拒。

  2. Charging Profile优先级与层级规则
    同一stackLevel下不能存在多个同类型Charging Profile(如两个TxProfile)。若清除操作未彻底移除原有stackLevel=1的TxProfile,新请求使用相同stackLevel会触发冲突。OCPP标准中stackLevel数值越小优先级越高,建议更新时要么确保原有配置已清除,要么用更高优先级的stackLevel(如0)覆盖。

  3. TxDefaultProfile生效条件
    TxDefaultProfile用于充电会话开始前的默认配置,但部分厂商(如ABB)设备要求该配置必须在**设备空闲(无活跃会话)**时设置,且需明确指定connectorId。此外,部分ABB型号仅支持Absolute类型的TxDefaultProfile,而非Relative。

二、ocpp-rpc库的潜在问题

结合参考信息,ocpp-rpc库可能存在以下问题:

  • 未正确校验transactionId与当前会话的绑定关系,导致请求中transactionId与设备侧活跃会话ID不匹配;
  • 发送ClearChargingProfile后未等待设备成功响应就立即发送新配置请求,此时设备可能仍在处理清除操作,无法接收新配置;
  • 对OCPP标准中stackLevel的优先级处理逻辑有疏漏,未自动处理同层级配置冲突。

三、解决方案建议

  1. 严格匹配会话ID
    发送SetChargingProfile(TxProfile类型)时,确保transactionId与当前活跃会话ID完全一致,可通过GetTransactionStatus请求获取会话ID后再发送配置请求。

  2. 等待清除操作完成
    调用ClearChargingProfile清除原有配置后,必须等待设备返回ClearChargingProfileResponse且状态为Accepted,再发送新的SetChargingProfile请求。

  3. 调整stackLevel或配置类型
    若无法确保原有配置被彻底清除,可将新配置的stackLevel设为比原有更小的数值(如0),利用优先级覆盖;对于TxDefaultProfile,尝试将chargingProfileKind改为Absolute后发送请求。

  4. 适配厂商设备特性
    查阅ABB充电器官方OCPP实现文档,确认对Charging Profile类型、参数的支持情况——比如部分型号要求TxDefaultProfile必须包含validFrom和validTo字段,或对limit数值范围有严格限制。

  5. 排查库的请求封装逻辑
    检查ocpp-rpc库对SetChargingProfile请求的封装是否符合OCPP标准,可通过抓包工具对比库发送的请求与标准报文格式是否一致,必要时手动构造请求测试。


内容的提问来源于stack exchange,提问作者lovestaco

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.09 05:09:57