HTTP API

ฟังก์ชันต่อไปนี้จัดเตรียมการแม็พของ Modbus Registers กับ 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 = meter1 หรือ meter2 หรือ evse
  • read = ที่อยู่ของการลงทะเบียนเพื่ออ่าน
  • write = ที่อยู่ของการลงทะเบียนเพื่ออ่าน
  • value = ค่าที่จะเขียน
  • values = อาร์เรย์ของค่าที่จะเขียนเช่น [1,2,3,4]

แอดเดรสสามารถมีส่วนต่อท้ายเพื่อระบุประเภทข้อมูล (ค่าเริ่มต้นคือ จำนวนเต็ม 16 บิต):

  • d = จำนวนเต็ม 32 บิต (2 modbus register)
  • q = จำนวนเต็ม 64 บิต (4 modbus register)
  • 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"

คำขอทั่วไป

ขอสถานะของอุปกรณ์ตัวจัดการการชาร์จทั้งหมด:
/cnf?cmd=get_dev_info

การตั้งค่า PIN หรือ RFID:
/cnf?cmd=enter_rfid&rfid=r&dev_id=d
r คือ PIN หรือ RFID (ตัวเลข) d คือ ID อุปกรณ์เสริมเพื่อเลือกวอลล์บ็อกซ์เฉพาะ หากไม่ได้เลือกรหัสอุปกรณ์ ตัวจัดการการชาร์จจะพยายามกำหนด PIN หรือ RFID โดยอัตโนมัติ

เขียนทับสำหรับธุรกรรมปัจจุบัน:
/cnf?cmd=override_device&dev_id=d&flags=f&mamps=ma&rfid=id
d คือรหัสอุปกรณ์ id เป็น RFID/PIN ที่อาจจำเป็น แฟล็กดังต่อไปนี้:
'C': ปิดใช้งานการโหลด (ต้องใช้ Admin pwd หรือ PIN ผู้ใช้/RFID)
'c': ปิดใช้งานการโหลดอีกครั้ง (ต้องใช้ Admin pwd หรือ PIN ผู้ใช้/RFID)
'E': ปิดใช้งานกฎการชาร์จของวอลล์บ็อกซ์ (จำเป็นต้องมีผู้ดูแลระบบ)
'e': ปิดใช้งานกฎการชาร์จของวอลล์บ็อกซ์อีกครั้ง (จำเป็นต้องมีผู้ดูแลระบบ)
'U': ปิดใช้งานกฎการชาร์จของผู้ใช้ (ต้องใช้ RFID ของผู้ใช้/PIN)
'u': ปิดใช้งานกฎการชาร์จของผู้ใช้อีกครั้ง (ผู้ใช้ต้องใช้ RFID/PIN)

แฟล็กที่ตั้งค่าในลักษณะนี้จะยังคงอยู่จนกว่ารถจะถอดปลั๊กออกจากวอลล์บ็อกซ์

mamps=ma: เขียนทับ (จำกัด) กระแสไฟชาร์จด้วย ma mA

การตั้งค่าเครื่องวัดพลังงานจำลอง:
/cnf?cmd=soft_meter&dev_id=d&val=v
v (ทางเลือก) คือพลังงานที่จะตั้งค่าเป็น Wh/VAh หากไม่มี v ตัวนับจะถูกอ่านเท่านั้น d คือรหัสอุปกรณ์ของ EVSE ค่าที่ส่งคืนคือการอ่านตัวนับแบบเก่าก่อนที่จะตั้งค่า

เคาน์เตอร์ HTTP และกล่องติดผนัง

เคาน์เตอร์

คุณสามารถสร้างตัวนับ (ประเภทอุปกรณ์ 'อินพุต HTTP') ที่ตัวจัดการการชาร์จไม่ได้อ่าน แต่สามารถระบุค่าปัจจุบันจากภายนอกได้โดยใช้ HTTP POST หรือ GET:
/cnf?cmd=set_ajax_meter&dev_id=x
x คือรหัสอุปกรณ์ตามที่เห็นในการกำหนดค่าอุปกรณ์เช่น 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 "รุ่น" คือสตริงรุ่นตามที่แสดงในไทล์

ผู้ใช้บางคนของเรา (#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 input meter และ ioBroker

วอลล์บ็อกซ์

คุณยังสามารถสร้างกล่องวอลล์ (ประเภทอุปกรณ์ 'อินพุต HTTP') ซึ่งไม่ได้อ่านออกหรือควบคุมโดยตัวจัดการการชาร์จ แต่สามารถระบุค่าภายนอกได้โดยใช้ HTTP POST หรือ GET ค่าควบคุมจะถูกส่งกลับเป็นการตอบสนอง:
/cnf?cmd=set_ajax_evse&dev_id=x
x คือรหัสอุปกรณ์ตามที่เห็นในการกำหนดค่าอุปกรณ์เช่น E1

เนื้อหา POST มีออบเจ็กต์ JSON ดังต่อไปนี้:

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

"model" คือสตริงโมเดลตามที่แสดงในไทล์ ด้วย "rfid" คุณสามารถเพิ่ม RFID ในกระบวนการชาร์จได้ค่าพลังงานจะได้รับเป็น Wh กระแสเป็น mA "state" มีค่าดังต่อไปนี้:
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": จริง/เท็จ // อุปกรณ์ถูกเปิด/ปิด
   "charging_enabled": จริง/เท็จ // ชาร์จ / ไม่อนุญาต
   "หยุดชั่วคราว": true/false, // true = อุปกรณ์หยุดชั่วคราว
   "charging_current": หมายเลข // กระแสไฟที่ระบุเป็น mA
}

วัตถุส่งคืนนี้ต้องได้รับการประเมินโดยผู้เรียกและต้องตั้งค่า EVSE ให้สอดคล้องกันเช่นกระแสไฟฟ้าที่ชาร์จจะต้องเปลี่ยนไปตามนั้น

Web interface (English)

All requests return an answer in JSON. Values marked with r/o are read-only. Please note: We do not guarantee the stability of this API. Functionality, parameters, values, etc. may change without notice.

Retrieve info about load-balancing and all devices

/cnf?cmd=get_dev_info
Return value (sample):
{
"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
}
]
}
         

Get/set Charging Manager parameters

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

HTTP GET get_params returns a JSON object, HTTP POST set_params needs a JSON object in the message body


Return value (sample):
//         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",
}         
         

Set device configuration

/cnf?cmd=set_params
POST payload (sample):
{
   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
   ]
}
         

Get / set user info

/cnf?cmd=get_users
/cnf?cmd=get_user
/cnf?cmd=set_user
*** ml: String not found [name='cfos_cm_sample_resp']:
:
// get_user retrieves a single user object, set_user POSTs a single user object, get_users retrieves an array of user objects
// set_user may be called without admin password if it contains a valid user ID, creation of new users requires admin access

[   // 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
]
}
]
         

Accept license:
/cnf?cmd=accept_license&acc=1&allow_usage_stats=a
a = 1 allow reporting of usage stats to cFos eMobililty, a = 0 disallow

Change admin password:
/cnf?cmd=change_admin_pwd&old_pwd=old&new_pwd=new
old, new are the old and new admin password

Delete a device:
/cnf?cmd=del_device&dev_id=d
d is a valid device ID

Get a unique user ID (for creation of a new user):
/cnf?cmd=get_new_user_id
returns a new user ID as a JSON string

Reset a device:
/cnf?cmd=reset_device&dev_id=d
d is a valid device ID. The device will be destroyed and re-created

Start stop diagnose logging:
/cnf?cmd=set_diag_logging&enable=e
e = 1 to start, e = 0 to stop diagnose logging. Runs for 5 minutes if not stopped