文件

HTTP API

以下功能提供了Modbus寄存器到HTTP的映射。
注意:Modbus不需要激活即可使用HTTP API。

使用HTTP GET或POST請求到cFos Power Brain Controller的地址,例如
http://192.168.2.111/cnf?cmd=modbus&device=meter1&read=35154
響應使用JSON。

  • cmd始終是modbus
  • device = meter1meter2evse
  • read =要讀取的寄存器地址
  • write =要讀取的寄存器地址
  • value =要寫入的值
  • values =要寫入的values數組,例如[1,2,3,4]

地址可以有一個後綴以指定數據類型(默認為16位整數):

  • d = 32位整數(2個Modbus寄存器)
  • q = 64位整數(4個Modbus寄存器)
  • s =字符串
cFos 充電控制器 - Modbus寄存器

這是一些示例,如何使用HTTP API

Modbus

/cnf?cmd=modbus&device=meter1&read=8002
響應:
1

/cnf?cmd=modbus&device=meter1&read=8062d
響應:
-1

/cnf?cmd=modbus&device=meter1&read=8016s
響應:
"cFos Power Brain"

/cnf?cmd=modbus&device=meter1&read=8002&count=10
響應:
[1,257,256,0,256,0,26211,26165,11619,13366]

/cnf?cmd=modbus&device=meter2&read=all
響應:
{"8000d":-821755904,"8002":1,"8003":257,"8004":16777216,"8006":256,"8007":0,"8008s":"fcf5-c46d-310c","8016s":"cFos Power Brain","8040":41,"8041":1,"8042d":1000,"8044":1,"8045":230,"8046":230,"8047":230,"8050q":0,"8054d":0,"8056":0,"8057":0,"8058q":0,"8062d":-1,"8064d":0,"8066d":0,"8068d":0,"8070":0,"8071":0,"8120d":0}

/cnf?cmd=modbus&device=evse&write=8044&value=7
響應:
"ok"

/cnf?cmd=modbus&device=evse&write=8050q&value=1"
響應:
"ok"

/cnf?cmd=modbus&device=evse&write=8044d&value=1"
響應:
"bad modbus register size"

/cnf?cmd=modbus&device=evse&write=8044&values=[7,230,230,230 ]
響應:
"ok"

一般要求

請求所有Charging Manager設備的狀態:
/cnf?cmd=get_dev_info

設置 PIN 或 RFID:
/cnf?cmd=enter_rfid&rfid=r&dev_id=d
r 是 PIN 或 RFID(數字),d 是用於選擇特定牆盒的可選設備 ID。如果未選擇設備 ID,充電管理器會嘗試自動分配 PIN 或 RFID。

覆蓋當前事務:
/cnf?cmd=override_device&dev_id=d&flags=f&mamps=ma&rfid=id
d 是設備 ID,id 是可能需要的 RFID/PIN,標誌如下:
'C':停用加載(需要管理員密碼或用戶 PIN/RFID)
'c':再次停用加載(需要管理員密碼或用戶 PIN/RFID)
'E': 停用 wallbox 的收費規則(需要管理員密碼)
'e':再次關閉wallbox的收費規則(需要管理員密碼)
'U':停用用戶收費規則(需要用戶 RFID/PIN)
'u':再次停用用戶的收費規則(需要用戶 RFID/PIN)

以這種方式設置的標誌會一直保留,直到汽車從 Wallbox 中拔出。

mamps=ma :用 ma mA 覆蓋(限制)充電電流。

設置模擬電能表:
/cnf?cmd=soft_meter&dev_id=d&val=v
v(可選)是以 Wh/VAh 為單位設置的能量。如果 v 不存在,則只讀取計數器。 d 是 EVSE 的設備 ID。返回值是設置之前的舊計數器讀數。

HTTP 計數器和壁箱

櫃檯

您可以創建一個無法被計費管理器讀取的計數器(設備類型 'HTTP Input'),但可以使用 HTTP POST 或 GET 在外部指定其當前值:
/cnf?cmd=set_ajax_meter&dev_id=x
x是在設備配置中看到的設備ID,例如M1

POST正文包含一個JSON對象,如下所示:

{
            "model": string,
            "import_vah": number,
            "export_wh": number,
            "voltage": [v1, v2, v3],
            "current": [c1, c2, c3],
            "power_w": number
            "is_va": bool
         }

能量值以 Wh 為單位,電壓以 V 為單位,電流以 mA 為單位,功率以 W 為單位。 “model”是磁貼中顯示的模型字符串。

我們的一些用戶 (#diebestenuserderwelt) 使用 curl 工具為計數器提供數據,例如:
curl -i -X POST -H 'Content-Type: application/json' -d '{ "model": "TestModell", "import_wh": 12345, "export_wh": 23456, "voltage": [231, 232, 233], "current": [10001, 10002, 10003] }' --user admin:1234abcd 'http://192.168.2.111/cnf?cmd=set_ajax_meter&dev_id=M3'

作為HTTP GET,請求是這樣寫的:
http://192.168.2.111/cnf?cmd=set_ajax_meter&dev_id=M3&model=TestModell&import_wh=12345&export_wh=23456&voltage=231,232,233&current=10001,10002,10003

這是使用 cFos HTTP 輸入儀表和 ioBroker 連接智能儀表的另一個論壇條目。

壁櫃

您還可以創建一個牆盒(設備類型'HTTP Input'),它不會被充電管理器讀取或控制,但可以使用 HTTP POST 或 GET 在外部指定其值。然後將控制值作為響應返回:
/cnf?cmd=set_ajax_evse&dev_id=x
x是在設備配置中看到的設備ID,例如E1

POST正文包含一個JSON對象,如下所示:

{
            "state": number,
            "max_charging_current": number,
            "current": [c1, c2, c3],
            "total_energy": number,
            "model": string,
            "rfid": string
         }

“模型”是模型字符串,如磁貼所示。借助“ rfid”,您可以在充電過程中添加RFID,能量值以Wh為單位,電流以mA為單位。 “狀態”具有以下值:
1 =等待(A), 2 =存在EV(B), 3 =充電(C), 4 =通風充電(D), 5 =錯誤(E)

作為一個 HTTP GET,請求是這樣寫的:
http://192.168.2.111/cnf?cmd=set_ajax_evse&dev_id=M3&model=TestModell&state=st&max_charging_current=m&current=c1,c2,c3&total_energy=t&rfid=r

作為響應,此請求返回以下JSON對象:

{
            “ device_enabled”:true/false, //設備已啟用/禁用
            “ charging_enabled”:正確/錯誤, //允許/不允許充電
            “ paused”:true/false, // true =設備暫時暫停
            “ charging_current”:數字//以mA為單位指定的充電電流
         }

該返回對象必須由調用方評估,並且必須相應地設置EVSE,例如,必須相應地更改充電電流。

網頁介面

所有請求都會傳回 JSON 格式的回應。標記為r/o的值是唯讀的。請注意:我們不保證該API的穩定性。功能、參數、值等如有變更,恕不另行通知。

檢索有關負載平衡器和所有設備的信息

/cnf?cmd=get_dev_info
返回值(範例):
         {
         "params" : {
         "title" : "cFos Power Brain",
         "desc" : "Standard-Konfiguration",
         "max_total_current" : 32000,   // total installed power in mA
         "reserve_current" : 0,   // reserve in mA (subtracted from max_total_current)       
         "overdraft_cur" : 0,       // generated overdraft in mA, can be set to 0
         "max_total_evse_current" : 0,   // max current available to all EVSEs in mA
         "cons_evse_power" : 0,    // r/o, consumed EVSE power in W
         "avail_evse_power" : 32000,   // r/o, available EVSE power in W
         "lb_enabled" : false,   // true: load balancing enabled, false: disabled (observation mode)
         "disable_policy" : 1,   // on device disable: 0 disable EVSE, 1 use min. charging current, -1 remove charging current limit (free charging)
         "cycle_time" : 3009,   // current update cycle time in msec
         "max_evses" : 3,   // maximum number of licensed EVSEs
         "shareware_mode" : false,   // false, if licensed, true if trial version
         "version" : "1.8.1095",
         "time" : 1645281534,   // current time stamp
         "vsn" : 
         {
         "vendorid" : 52997,   // cFos
         },
         "ocpp_gateway_license_cnt" : 0,  // number of licensed OCPP gateways
         "ocpp_gateway_licenses_used" : 0   // number of used OCPP gateways
         },
         "devices" : [   // array of configured devices
         {
         "dev_type" : "evse_powerbrain",   // a sample EVSE
         "device_enabled" : 1,   // 1 = device enabled, 0 = disabled
         "name" : "Wallbox",   // config item: name
         "address" : "evse",   // address: URL, IP address or COM Port + Parameters
         "id" : 1,   // Modbus ID
         "dev_id" : "E1",   // unique device ID, EVSE always begin with E
         "number" : 1,   // config item: number
         "desc" : "cFos Power Brain Wallbox 11kW",   // config item: description
         "com_err" : false,   // true, if active communication error
         "com_err_secs" : 1404660,   // time since last com error
         "com_errors" : 0,   // number of com errors
         "last_error" : "",   // text of last error
         "is_evse" : true,   // true for EVSEs, false for meters
         "used_phases" : 0,   // 0=determine, otherwise bitfield: bit0 L1, bit1 L2, bit2 L3
         "label" : "",   // config item: text displayed when plugged in
         "min_charging_cur" : 6000,   // minimum charging current in mA
         "max_charging_cur" : 11040,   // maximum charging current in mA or expression
         "prio" : 1,   // charging priority
         "charging_enabled" : true,   // r/o, true if charging allowed
         "cur_charging_power" : 0,   // r/o, current charging power in W
         "total_energy" : 7120572,   // r/o, total used charging energy in Wh
         "phases" : 0,   // currently used phases, bitfield: bit0 L1, bit1 L2, bit2 L3
         "state" : 1,   // 1 = waiting for EV, 2 = EV presend, 3 = charging, 4 = charging/vent, 5 = error, 6 = offline
         "model" : "cFos Power Brain,1.0,1.8.1095,6d-31-0c",   // r/o, model string: Manufacturer,device,device version, firmware version, serial number
         "paused" : false,   // true, if device paused due to energy shortage or phase imbalance
         "pause_time" : 300,   // current elapsed pause time in secs
         "pause_min_time" : 300,   // min. secs before end of pause
         {
         "dev_type" : "meter_powerbrain",  // a sample meter
         "device_enabled" : 1,   // 1 = device enabled, 0 = disabled
         "name" : "S0 Zähler 1",   // config item: name
         "address" : "meter1",   // address: URL, IP address or COM Port + Parameters
         "id" : 2,   // Modbus ID
         "dev_id" : "M1",   // unique device ID, meters always begin with M
         "number" : 1,   // config item: number
         "desc" : "cFos Power Brain, S0 Zähler 1",   // config item: description
         "com_err" : false,   // true, if active communication error
         "com_err_secs" : 1404660,   // time since last com error
         "com_errors" : 0,   // number of com errors
         "last_error" : "",   // text of last error
         "is_evse" : true,   // true for EVSEs, false for meters
         "used_phases" : 0,   // 0=determine, otherwise bitfield: bit0 L1, bit1 L2, bit2 L3
         "is_va" : false,   // true if display is VA, false for W
         "invert" : false,   // if true, current and power values are inverted
         "import" : 15,   // imported energy in Wh
         "export" : 0,   // exported energy in Wh
         "power_w" : 0,   // current active power in W
         "current_l1" : 0,   // current L1 in mA
         "current_l2" : 0,   // current L2 in mA
         "current_l3" : 0,   // current L3 in mA
         "voltage_l1" : 230,   // Voltage L1 in V
         "voltage_l2" : 230,   // Voltage L2 in V
         "voltage_l3" : 230,   // Voltage L31 in V
         "role" : 0,   // 0 = display, 1 = consumption, 2 = production, 3 = grid demand, 4 = vehicle consumption, 5 = storage
         "model" : "cFos Power Brain,1.0,1.8.1095,6d-31-0c"   // r/o, model string: Manufacturer,device,device version, firmware version, serial number
         }
         ]
         }
                  

設定/讀取充電管理器參數

/cnf?cmd=get_params
/cnf?cmd=set_params

HTTP GET get_params傳回一個 JSON 對象,
HTTP POST set_params需要訊息正文中的 JSON 對象

返回值(範例):
         //         see values for get_dev_info.
         //        In Addition there is a device meta struct to allow for selection of device types:
         "dev_meta": 
         {
         "evse_powerbrain" : "cFos Power Brain",   // EVSE device type : name
         "evse_mennekes_modbus" : "Heidelberg Energy Control",
         "meter_elenker_meter" : "ModbusMeter 5A",   // meter device type : name
         "meter_kostal_powermeter" : "Kostal Powermeter",
         "meter_orno_we516" : "Orno OR-WE-516",
         }         
                  

設定設備設定

/cnf?cmd=set_params
POST 有效負載(範例):
         {
            devices: [   // array of device objects, currently may only contain 1 device
            {   // for most of the device properties, see get_dev_info
         attach: ""   // device ID of an attached meter
         battery_save_threshold: 0   // in mA, if charging current falls below this threshold, charging will be stopped, 0 = disable
         charging_rules: [   // array of charging rules
         // charging rules are work in progress, expect frequent changes to their object layout.
         {
            "days": d,     // d is a bitfields a weekdays: bit0 Monday...bit6 Sunday
            "mode": m,     // m mode of the rule: 0=absolule current, 1=relative current, 2=current solar current, 3=relative current solar current, 4=solar current minus current value, 5=solar surplus
            "current": c,  // c current in mA
            "enabled": e,  // e = true for an active rule, false for ignored rules
            "udur": u,     // u = undercut duration in secs
            "time": t      // t in minutes after midnight (for time based rules)
            "dur":  dur    // dur in minutes (for time based rules)
            "expr": expr   // expr is evaluated to determine the rule current (for expression rules)
            "input": in    // in = string specifying the input and level (for input based rules)
            "price_level", p   // p = price level (for cost baseed rules)
            "solar": s     // solar current in mA (for solar based rules)
         }
         ]
         enable_snooze: true   // true, allow device snooze
         enable_wakeup: true   // true, allow device wakeup for charging
         fixed_rfid: ""   // use fixed RFID for OCPP
         group: 0   // device belongs to this group, 0 = main group
         ocpp_gateway_client_id: "CP42"
         phase_rotation: 0
         soft_meter: 7120572   // estimated charged energy in W (if device has no meter)
         users: ["1170223812"]   // array of user ids which are allowed to charge at this EVSE
            ]
         }
                  

Benutzerinformationen setzen/auslesen

/cnf?cmd=get_users
/cnf?cmd=get_user
/cnf?cmd=set_user

get_user取得單一使用者對象,
set_user POST 單一使用者對象,
get_users取得使用者物件數組
如果set_user包含有效的使用者 ID,則無需管理員密碼即可存取它。建立新使用者需要管理員權限

返回值(範例):
         [   // array of users
         {
         "id" : "2167520770",   // unique user ID
         "name" : "wusel",   // name
         "display" : true,   // true if user may be displayed while plugged in
         "dev_ids" :    // EVSEs the user may use
         [
         "E1"
         ],
         "rfids" : 
         [   // array of RFIDs
         {
         "id" : "4711",   // RFID / PIN
         "name" : "TeSt",   // Name
         "ac_auth" : true,   // true: used to authorize
         "ac_ovch" : false,  // true: used to stop charging
         "used_phases" : 7   // used to override used phases, 0 = don't override
         }
         ],
         "charging_rules" : 
         [   // array of charging rules for this user
         ]
         }
         ]
                  

接受許可

/cnf?cmd=accept_license&acc=1&allow_usage_stats=a
a = 1允許將使用統計資訊報告給 cFos eMobililty, a = 0禁止

更改管理員密碼

/cnf?cmd=change_admin_pwd&old_pwd=alt&new_pwd=neu
oldnew是舊的和新的管理員密碼

刪除設備

/cnf?cmd=del_device&dev_id=d
d是有效的設備 ID

取得唯一的使用者ID(用於建立新使用者)

/cnf?cmd=get_new_user_id
以 JSON 字串形式傳回新的使用者 ID

重置設備

/cnf?cmd=reset_device&dev_id=d
d是有效的設備 ID。該設備將被刪除並重新創建

啟動/停止診斷日誌記錄

/cnf?cmd=set_diag_logging&enable=e
e = 1啟動, e = 0停止診斷記錄。如果不停止則運轉 5 分鐘