forked from opengd/solar-sis
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request opengd#5 from geeks-r-us/master
added support fpr UB2000 LiFePo4 Batteries from PylonTech
- Loading branch information
Showing
9 changed files
with
433 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,223 @@ | ||
{ | ||
"query_config": { | ||
"start_bit": "", | ||
"command_type": "P", | ||
"response_type": "D", | ||
"data_length_bits": 3, | ||
"seperator": " ", | ||
"ending_character": "\r", | ||
"crc_length": 2, | ||
"response_start": "~", | ||
"response_header_length": 14 | ||
}, | ||
"query": { | ||
"get_analog_value": { | ||
"command": "~20014642E002FFFD0A", | ||
"influx": true, | ||
"cache": true, | ||
"LENID": 2, | ||
"crc16": false, | ||
"variables": { | ||
"Command": 1 | ||
}, | ||
"response": { | ||
"Ammount_of_Pack": 1, | ||
"Cells_count": 1, | ||
"Cell1_voltage": -2, | ||
"Cell2_voltage": -2, | ||
"Cell3_voltage": -2, | ||
"Cell4_voltage": -2, | ||
"Cell5_voltage": -2, | ||
"Cell6_voltage": -2, | ||
"Cell7_voltage": -2, | ||
"Cell8_voltage": -2, | ||
"Cell9_voltage": -2, | ||
"Cell10_voltage": -2, | ||
"Cell11_voltage": -2, | ||
"Cell12_voltage": -2, | ||
"Cell13_voltage": -2, | ||
"Cell14_voltage": -2, | ||
"Cell15_voltage": -2, | ||
"Temperature_count": 1, | ||
"Temperature_1": -2, | ||
"Temperature_2": -2, | ||
"Temperature_3": -2, | ||
"Temperature_4": -2, | ||
"Temperature_5": -2, | ||
"Pack_current": -2, | ||
"Pack_voltage": 2, | ||
"Pack_remains_mAh": 2, | ||
"User_defined": 1, | ||
"Pack_total_mAh": 2, | ||
"Pack_cycle": 2, | ||
"Cells_count_P2": 1, | ||
"Cell1_voltage_P2": -2, | ||
"Cell2_voltage_P2": -2, | ||
"Cell3_voltage_P2": -2, | ||
"Cell4_voltage_P2": -2, | ||
"Cell5_voltage_P2": -2, | ||
"Cell6_voltage_P2": -2, | ||
"Cell7_voltage_P2": -2, | ||
"Cell8_voltage_P2": -2, | ||
"Cell9_voltage_P2": -2, | ||
"Cell10_voltage_P2": -2, | ||
"Cell11_voltage_P2": -2, | ||
"Cell12_voltage_P2": -2, | ||
"Cell13_voltage_P2": -2, | ||
"Cell14_voltage_P2": -2, | ||
"Cell15_voltage_P2": -2, | ||
"Temperature_count_P2": 1, | ||
"Temperature_1_P2": -2, | ||
"Temperature_2_P2": -2, | ||
"Temperature_3_P2": -2, | ||
"Temperature_4_P2": -2, | ||
"Temperature_5_P2": -2, | ||
"Pack_current_P2": -2, | ||
"Pack_voltage_P2": 2, | ||
"Pack_remains_mAh_P2": 2, | ||
"User_defined_P2": 1, | ||
"Pack_total_mAh_P2": 2, | ||
"Pack_cycle_P2": 2, | ||
"Cells_count_P3": 1, | ||
"Cell1_voltage_P3": -2, | ||
"Cell2_voltage_P3": -2, | ||
"Cell3_voltage_P3": -2, | ||
"Cell4_voltage_P3": -2, | ||
"Cell5_voltage_P3": -2, | ||
"Cell6_voltage_P3": -2, | ||
"Cell7_voltage_P3": -2, | ||
"Cell8_voltage_P3": -2, | ||
"Cell9_voltage_P3": -2, | ||
"Cell10_voltage_P3": -2, | ||
"Cell11_voltage_P3": -2, | ||
"Cell12_voltage_P3": -2, | ||
"Cell13_voltage_P3": -2, | ||
"Cell14_voltage_P3": -2, | ||
"Cell15_voltage_P3": -2, | ||
"Temperature_count_P3": 1, | ||
"Temperature_1_P3": -2, | ||
"Temperature_2_P3": -2, | ||
"Temperature_3_P3": -2, | ||
"Temperature_4_P3": -2, | ||
"Temperature_5_P3": -2, | ||
"Pack_current_P3": -2, | ||
"Pack_voltage_P3": 2, | ||
"Pack_remains_mAh_P3": 2, | ||
"User_defined_P3": 1, | ||
"Pack_total_mAh_P3": 2, | ||
"Pack_cycle_P3": 2, | ||
"Cells_count_P4": 1, | ||
"Cell1_voltage_P4": -2, | ||
"Cell2_voltage_P4": -2, | ||
"Cell3_voltage_P4": -2, | ||
"Cell4_voltage_P4": -2, | ||
"Cell5_voltage_P4": -2, | ||
"Cell6_voltage_P4": -2, | ||
"Cell7_voltage_P4": -2, | ||
"Cell8_voltage_P4": -2, | ||
"Cell9_voltage_P4": -2, | ||
"Cell10_voltage_P4": -2, | ||
"Cell11_voltage_P4": -2, | ||
"Cell12_voltage_P4": -2, | ||
"Cell13_voltage_P4": -2, | ||
"Cell14_voltage_P4": -2, | ||
"Cell15_voltage_P4": -2, | ||
"Temperature_count_P4": 1, | ||
"Temperature_1_P4": -2, | ||
"Temperature_2_P4": -2, | ||
"Temperature_3_P4": -2, | ||
"Temperature_4_P4": -2, | ||
"Temperature_5_P4": -2, | ||
"Pack_current_P4": -2, | ||
"Pack_voltage_P4": 2, | ||
"Pack_remains_mAh_P4": 2, | ||
"User_defined_P4": 1, | ||
"Pack_total_mAh_P4": 2, | ||
"Pack_cycle_P4": 2 | ||
}, | ||
"MQTTConfig": { | ||
"Pack_current": 1, | ||
"Pack_current_P2": 1, | ||
"Pack_current_P3": 1, | ||
"Pack_current_P4": 1, | ||
"Pack_remains_mAh": 2, | ||
"Pack_remains_mAh_P2": 2, | ||
"Pack_remains_mAh_P3": 2, | ||
"Pack_remains_mAh_P4": 2 | ||
} | ||
} | ||
}, | ||
"set_config": { | ||
"start_bit": "", | ||
"command_type": "S", | ||
"response_type": "", | ||
"data_length_bits": 0, | ||
"seperator": " ", | ||
"ending_character": "\r", | ||
"crc_length": 2, | ||
"crc16":true, | ||
"response_accept_command": 1, | ||
"response_refuse_command": 0, | ||
"variable_length_fillout": "0", | ||
"response_start": "(", | ||
"response_header_length": 0 | ||
}, | ||
"set": { | ||
"output_source_priority" : { | ||
"command" : "POP", | ||
"crc16": true, | ||
"variables": { | ||
"source": "" | ||
} | ||
}, | ||
"charger_priority": { | ||
"command" : "PCP", | ||
"crc16": true, | ||
"variables" : { | ||
"source" : "" | ||
} | ||
}, | ||
"bulk_charging": { | ||
"command" : "PCVV", | ||
"crc16": true, | ||
"variables" : { | ||
"voltage" : "" | ||
} | ||
}, | ||
"float_charging": { | ||
"command" : "PBFT", | ||
"crc16": true, | ||
"variables" : { | ||
"voltage" : "" | ||
} | ||
}, | ||
"utility_max_charging": { | ||
"command" : "MUCHGC0", | ||
"crc16": true, | ||
"variables" : { | ||
"current" : "" | ||
} | ||
}, | ||
"max_charging": { | ||
"command" : "MCHGC0", | ||
"crc16": true, | ||
"variables" : { | ||
"current" : "" | ||
} | ||
}, | ||
"back_to_grid": { | ||
"command" : "PBCV", | ||
"crc16": true, | ||
"variables" : { | ||
"voltage" : "" | ||
} | ||
}, | ||
"back_to_battery": { | ||
"command" : "PBDV", | ||
"crc16": true, | ||
"variables" : { | ||
"voltage" : "" | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"name": "solar-sis_pylon", | ||
"version": "1.0.1", | ||
"dependencies": { | ||
"solar-sis": "latest", | ||
"serialport": "4.0.7" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
'use strict'; | ||
|
||
var mpi = require("../../index"); | ||
|
||
var mqtt = require('mqtt') | ||
var client = mqtt.connect('mqtt://localhost') | ||
|
||
function MyMpiCallbacks () { | ||
var fr = 0; | ||
var fs = 0; | ||
var ft = 0; | ||
|
||
this.power_status = function (qc, data, arr, json, influx) { | ||
//console.log("mpi_power: influx : " + influx); | ||
//mpi.SendDataToInflux('mpi_power ' + influx); | ||
|
||
client.publish('solar/pylon', (Number(arr[0]) + Number(arr[1])).toString()); | ||
} | ||
|
||
this.feeding_grid_power_calibration = function (qc, data, arr) { | ||
//console.log("feeding_grid_power_calibration: " + data); | ||
//console.log("feeding_grid_power_calibration: arr: " + arr); | ||
|
||
fr = arr[3]; | ||
fs = arr[5]; | ||
ft = arr[7]; | ||
|
||
console.log("fr: " + fr + " fs: " + fs + " ft: " + ft); | ||
|
||
if (data) { | ||
mpi.SendDataToInflux('mpi_calibration fas_r=' + fr + ',fas_s=' + fs + ',fas_t=' + ft); | ||
} | ||
} | ||
|
||
this.before_f1 = function (values) { | ||
console.log("fr: " + fr + " fs: " + fs + " ft: " + ft); | ||
|
||
var watt = values.w; | ||
var fase = values.f; | ||
|
||
if (values.a == 1) { | ||
if (fase == 'R') { watt = Number(fr) + Number(watt);} | ||
if (fase == 'S') { watt = Number(fs) + Number(watt);} | ||
if (fase == 'T') { watt = Number(ft) + Number(watt);} | ||
} | ||
|
||
console.log('watt: ' + watt + ' fase:' + fase); | ||
|
||
return ({"fase" : fase + "ADJ1", "watt" : watt}); | ||
} | ||
|
||
this.callback_f1 = function (qc, data, arr) { | ||
myMpi.SendQuickCommand("feeding_grid_power_calibration"); | ||
} | ||
|
||
this.customMerge = function(json, queryValues) { | ||
var c = 0; | ||
var respvalue = 0; | ||
var ByteNum = 0; | ||
//console.log('queryvalues: ' + JSON.stringify(queryValues)); | ||
var data = queryValues[0] | ||
var s = JSON.parse(JSON.stringify(json), (key, value) => { | ||
if (typeof value === 'number') { | ||
if (value > 0) { | ||
ByteNum = value; | ||
respvalue = parseInt(data.substring(c, c+2*ByteNum),16); | ||
//console.log("key: " + key + " value: " + value + ' c: ' + c + ' ByteNum: ' + ByteNum + ' respvalue: ' + respvalue); | ||
} | ||
else { | ||
ByteNum = -value; | ||
respvalue = parseInt(data.substring(c, c+2*ByteNum),16); | ||
if (respvalue > 0x7FFF) respvalue = respvalue - 0xFFFF; | ||
//console.log("key: " + key + " value: " + value + ' c: ' + c + ' ByteNum: ' + ByteNum + ' respvalue: ' + respvalue); | ||
} | ||
c+= 2*ByteNum; | ||
return respvalue; | ||
} | ||
else return value; | ||
}); | ||
|
||
return s; | ||
} | ||
} | ||
|
||
var myMpi = new mpi.mpi(); | ||
var callbacks = new MyMpiCallbacks(); | ||
myMpi.init(callbacks); |
Oops, something went wrong.