diff --git a/CHANGELOG.md b/CHANGELOG.md index 5128bfc9..f48fb333 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -71,6 +71,7 @@ * Changed: JKBMS BLE - Fixes wrong max battery voltage https://github.com/Louisvdw/dbus-serialbattery/issues/1094 by @mr-manuel * Changed: JKBMS PB Model fixes by @KoljaWindeler * Changed: Reworked, documented and cleaned up a lot of code by @mr-manuel +* Changed: Set default charge/discharge current from utils in main battery class by @mr-manuel * Changed: The setting `HELTEC_MODBUS_ADDR` was replaced by `MODBUS_ADDRESSES` in the `config.default.ini` by @mr-manuel * Changed: Updated `battery_template.py` and added tons of descriptions by @mr-manuel diff --git a/etc/dbus-serialbattery/battery.py b/etc/dbus-serialbattery/battery.py index daad2cd2..3df31419 100644 --- a/etc/dbus-serialbattery/battery.py +++ b/etc/dbus-serialbattery/battery.py @@ -164,8 +164,8 @@ def __init__(self, port: str, baud: int, address: str): self.hardware_version: str = None self.cell_count: int = None # max battery charge/discharge current - self.max_battery_charge_current: float = None - self.max_battery_discharge_current: float = None + self.max_battery_charge_current: float = utils.MAX_BATTERY_CHARGE_CURRENT + self.max_battery_discharge_current: float = utils.MAX_BATTERY_DISCHARGE_CURRENT self.has_settings: bool = False # this values should only be initialized once, diff --git a/etc/dbus-serialbattery/bms/ant.py b/etc/dbus-serialbattery/bms/ant.py index 40adea7f..ce30edca 100644 --- a/etc/dbus-serialbattery/bms/ant.py +++ b/etc/dbus-serialbattery/bms/ant.py @@ -57,8 +57,6 @@ def get_settings(self): # After successful connection get_settings() will be called to set up the battery # Set the current limits, populate cell count, etc # Return True if success, False for failure - self.max_battery_charge_current = utils.MAX_BATTERY_CHARGE_CURRENT - self.max_battery_discharge_current = utils.MAX_BATTERY_DISCHARGE_CURRENT self.version = "ANT BMS V2.0" logger.info(self.hardware_version) return True diff --git a/etc/dbus-serialbattery/bms/daly.py b/etc/dbus-serialbattery/bms/daly.py index cf47cd93..7a788811 100644 --- a/etc/dbus-serialbattery/bms/daly.py +++ b/etc/dbus-serialbattery/bms/daly.py @@ -100,8 +100,6 @@ def get_settings(self, ser): self.read_capacity(ser) self.read_production_date(ser) - self.max_battery_charge_current = utils.MAX_BATTERY_CHARGE_CURRENT - self.max_battery_discharge_current = utils.MAX_BATTERY_DISCHARGE_CURRENT return True def refresh_data(self): diff --git a/etc/dbus-serialbattery/bms/daly_can.py b/etc/dbus-serialbattery/bms/daly_can.py index 68bd1235..d0bc3b6d 100644 --- a/etc/dbus-serialbattery/bms/daly_can.py +++ b/etc/dbus-serialbattery/bms/daly_can.py @@ -115,8 +115,7 @@ def test_connection(self): def get_settings(self): self.capacity = BATTERY_CAPACITY - self.max_battery_charge_current = MAX_BATTERY_CHARGE_CURRENT - self.max_battery_discharge_current = MAX_BATTERY_DISCHARGE_CURRENT + return True def refresh_data(self): diff --git a/etc/dbus-serialbattery/bms/ecs.py b/etc/dbus-serialbattery/bms/ecs.py index 681f03c3..f3c49c02 100644 --- a/etc/dbus-serialbattery/bms/ecs.py +++ b/etc/dbus-serialbattery/bms/ecs.py @@ -104,8 +104,6 @@ def get_settings(self): # Return True if success, False for failure # Uncomment if BMS does not supply capacity - self.max_battery_charge_current = utils.MAX_BATTERY_CHARGE_CURRENT - self.max_battery_discharge_current = utils.MAX_BATTERY_DISCHARGE_CURRENT self.cell_count = utils.LIPRO_CELL_COUNT self.max_battery_voltage = utils.MAX_CELL_VOLTAGE * self.cell_count self.min_battery_voltage = utils.MIN_CELL_VOLTAGE * self.cell_count diff --git a/etc/dbus-serialbattery/bms/eg4_lifepower.py b/etc/dbus-serialbattery/bms/eg4_lifepower.py index 5d42e08b..ff5afd78 100644 --- a/etc/dbus-serialbattery/bms/eg4_lifepower.py +++ b/etc/dbus-serialbattery/bms/eg4_lifepower.py @@ -55,8 +55,6 @@ def get_settings(self): # After successful connection get_settings() will be called to set up the battery # Set the current limits, populate cell count, etc # Return True if success, False for failure - self.max_battery_charge_current = utils.MAX_BATTERY_CHARGE_CURRENT - self.max_battery_discharge_current = utils.MAX_BATTERY_DISCHARGE_CURRENT hardware_version = self.read_serial_data_eg4(self.command_hardware_version) if hardware_version: # I get some characters that I'm not able to figure out the encoding, probably chinese so I discard it diff --git a/etc/dbus-serialbattery/bms/eg4_ll.py b/etc/dbus-serialbattery/bms/eg4_ll.py index c5deae5f..c9d9ec07 100644 --- a/etc/dbus-serialbattery/bms/eg4_ll.py +++ b/etc/dbus-serialbattery/bms/eg4_ll.py @@ -137,9 +137,6 @@ def get_settings(self): self.min_battery_voltage = utils.MIN_CELL_VOLTAGE * self.cell_count self.max_battery_voltage = utils.MAX_CELL_VOLTAGE * self.cell_count - self.max_battery_charge_current = utils.MAX_BATTERY_CHARGE_CURRENT - self.max_battery_discharge_current = utils.MAX_BATTERY_DISCHARGE_CURRENT - # self.balancer_voltage = int.from_bytes(config_results[25:27], "big")/1000 # self.balancer_current_delta = int.from_bytes(config_results[27:29], "big")/1000 diff --git a/etc/dbus-serialbattery/bms/hlpdatabms4s.py b/etc/dbus-serialbattery/bms/hlpdatabms4s.py index b9f2eedc..9b0c4867 100644 --- a/etc/dbus-serialbattery/bms/hlpdatabms4s.py +++ b/etc/dbus-serialbattery/bms/hlpdatabms4s.py @@ -1,7 +1,6 @@ # -*- coding: utf-8 -*- from battery import Battery, Cell from utils import logger -import utils import serial from time import sleep import sys @@ -79,8 +78,6 @@ def read_test_data(self): if ix > 0: self.hardware_version = s1[ix : len(s1) - 1] self.version = self.hardware_version - self.max_battery_charge_current = utils.MAX_BATTERY_CHARGE_CURRENT - self.max_battery_discharge_current = utils.MAX_BATTERY_DISCHARGE_CURRENT self.poll_interval = 10000 self.control_discharge_current = 1000 self.control_charge_current = 1000 diff --git a/etc/dbus-serialbattery/bms/jkbms_can.py b/etc/dbus-serialbattery/bms/jkbms_can.py index a773434b..5ebabf07 100644 --- a/etc/dbus-serialbattery/bms/jkbms_can.py +++ b/etc/dbus-serialbattery/bms/jkbms_can.py @@ -9,8 +9,6 @@ from utils import ( is_bit_set, logger, - MAX_BATTERY_CHARGE_CURRENT, - MAX_BATTERY_DISCHARGE_CURRENT, MAX_CELL_VOLTAGE, MIN_CELL_VOLTAGE, JKBMS_CAN_CELL_COUNT, @@ -92,8 +90,7 @@ def get_settings(self): # Set the current limits, populate cell count, etc # Return True if success, False for failure self.cell_count = JKBMS_CAN_CELL_COUNT - self.max_battery_charge_current = MAX_BATTERY_CHARGE_CURRENT - self.max_battery_discharge_current = MAX_BATTERY_DISCHARGE_CURRENT + self.max_battery_voltage = MAX_CELL_VOLTAGE * self.cell_count self.min_battery_voltage = MIN_CELL_VOLTAGE * self.cell_count diff --git a/etc/dbus-serialbattery/bms/lltjbd.py b/etc/dbus-serialbattery/bms/lltjbd.py index 4e760158..3901fa74 100644 --- a/etc/dbus-serialbattery/bms/lltjbd.py +++ b/etc/dbus-serialbattery/bms/lltjbd.py @@ -298,9 +298,6 @@ def get_settings(self): if not self.read_gen_data(): return False - self.max_battery_charge_current = utils.MAX_BATTERY_CHARGE_CURRENT - self.max_battery_discharge_current = utils.MAX_BATTERY_DISCHARGE_CURRENT - with self.eeprom(writable=False): cycle_cap = self.read_serial_data_llt(readCmd(REG_CYCLE_CAP)) diff --git a/etc/dbus-serialbattery/bms/mnb.py b/etc/dbus-serialbattery/bms/mnb.py index 4ee897a9..96aeac49 100644 --- a/etc/dbus-serialbattery/bms/mnb.py +++ b/etc/dbus-serialbattery/bms/mnb.py @@ -76,8 +76,6 @@ def __init__(self, port, baud, address=0): self.poll_interval = None self.type = self.BATTERYTYPE self.inst_capacity = None - self.max_battery_charge_current = None - self.max_battery_discharge_current = None self.V_C_min = None self.V_C_max = None self.max_battery_voltage = None diff --git a/etc/dbus-serialbattery/bms/renogy.py b/etc/dbus-serialbattery/bms/renogy.py index 046fc7e9..0f613e15 100644 --- a/etc/dbus-serialbattery/bms/renogy.py +++ b/etc/dbus-serialbattery/bms/renogy.py @@ -83,11 +83,9 @@ def get_settings(self): # After successful connection get_settings() will be called to set up the battery # Set the current limits, populate cell count, etc # Return True if success, False for failure - self.max_battery_charge_current = utils.MAX_BATTERY_CHARGE_CURRENT - self.max_battery_discharge_current = utils.MAX_BATTERY_DISCHARGE_CURRENT - self.max_battery_voltage = utils.MAX_CELL_VOLTAGE * self.cell_count self.min_battery_voltage = utils.MIN_CELL_VOLTAGE * self.cell_count + return True def refresh_data(self): diff --git a/etc/dbus-serialbattery/bms/revov.py b/etc/dbus-serialbattery/bms/revov.py index 3865fef4..48c48547 100644 --- a/etc/dbus-serialbattery/bms/revov.py +++ b/etc/dbus-serialbattery/bms/revov.py @@ -82,8 +82,6 @@ def get_settings(self): # Set the current limits, populate cell count, etc # Return True if success, False for failure - self.max_battery_charge_current = MAX_BATTERY_CHARGE_CURRENT - self.max_battery_discharge_current = MAX_BATTERY_DISCHARGE_CURRENT self.max_battery_voltage = MAX_CELL_VOLTAGE * self.cell_count self.min_battery_voltage = MIN_CELL_VOLTAGE * self.cell_count # Need to fix to use correct value will do later. hard coded for now diff --git a/etc/dbus-serialbattery/bms/seplos.py b/etc/dbus-serialbattery/bms/seplos.py index 0d18fd65..d634f14e 100644 --- a/etc/dbus-serialbattery/bms/seplos.py +++ b/etc/dbus-serialbattery/bms/seplos.py @@ -120,8 +120,8 @@ def get_settings(self): # Return True if success, False for failure # BMS does not provide max charge-/discharge, so we have to use hardcoded/config values - self.max_battery_charge_current = utils.MAX_BATTERY_CHARGE_CURRENT - self.max_battery_discharge_current = utils.MAX_BATTERY_DISCHARGE_CURRENT + # self.max_battery_charge_current = utils.MAX_BATTERY_CHARGE_CURRENT + # self.max_battery_discharge_current = utils.MAX_BATTERY_DISCHARGE_CURRENT self.max_battery_voltage = utils.MAX_CELL_VOLTAGE * self.cell_count self.min_battery_voltage = utils.MIN_CELL_VOLTAGE * self.cell_count diff --git a/etc/dbus-serialbattery/bms/sinowealth.py b/etc/dbus-serialbattery/bms/sinowealth.py index 3033d323..6dcbbf05 100644 --- a/etc/dbus-serialbattery/bms/sinowealth.py +++ b/etc/dbus-serialbattery/bms/sinowealth.py @@ -69,8 +69,8 @@ def test_connection(self): def get_settings(self): # hardcoded parameters, to be requested from the BMS in the future - self.max_battery_charge_current = utils.MAX_BATTERY_CHARGE_CURRENT - self.max_battery_discharge_current = utils.MAX_BATTERY_DISCHARGE_CURRENT + # self.max_battery_charge_current = utils.MAX_BATTERY_CHARGE_CURRENT + # self.max_battery_discharge_current = utils.MAX_BATTERY_DISCHARGE_CURRENT if self.cell_count is None: self.read_pack_config_data()