This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

iBMS integration
#1
Recenlly I bought an iBMS interface for reading data for my home battery system with a JK BMS.  Can anyone help me with a basic script? The iBMS has an API which provides data bij HTML. I removed some data, but the structure is:

{
"device": "iBMS-Master",
"board_type": 1,
"charge_current": 100,
"discharge_current": 100,
"capacity_remaining": 79,

"battery_soh": 100,
"batteries": [{
    "id": 0,
    "total_voltage": 53.12,
    "current": -0.48,
    "total_runtime": 17388365
 }, {
   "id": 1,
   "total_voltage": 53.06,
   "current": 0,
  "total_runtime": 27409539
}]
}
Reply
#2
Try this. Change url and group address mapping as needed.
Code:
json = require('json') http = require('socket.http') url = 'http://192.168.1.1/' res, err = http.request(url) if not res then   log('request failed', err) else   res, err = json.pdecode(res)   if not res then     log('failed to parse response', err)   else     grp.checkwrite('1/1/1', res.charge_current)     grp.checkwrite('1/1/2', res.discharge_current)     grp.checkwrite('1/1/3', res.capacity_remaining)     grp.checkwrite('1/1/4', res.battery_soh)     grp.checkwrite('1/2/1', res.batteries[1].total_voltage)     grp.checkwrite('1/2/2', res.batteries[1].current)     grp.checkwrite('1/3/1', res.batteries[2].total_voltage)     grp.checkwrite('1/3/2', res.batteries[2].current)   end end
Reply


Forum Jump: