Skip to content

Commit

Permalink
fixed calculation errors
Browse files Browse the repository at this point in the history
  • Loading branch information
mr-manuel committed May 10, 2023
1 parent 8045696 commit cd1bda7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
# Changelog

## v1.0.4
* Changed: Fixed errors for `MinVoltageCellId`, `MinCellVoltage`, `MaxVoltageCellId` and `MaxCellVoltage` calculations
* Changed: Improved error handling and output

## v1.0.3
* Added: Check if provided values are string, integer or float
* Changed: Time-To-Go can now be configured in the config file. When charging the battery it's calculating the time to 100% SoC and when discharging it's calculating the time to the SoC configured in the config file.
* Changed: Time-To-Go can now be configured in the config file. When charging the battery it's calculating the time to 100% SoC and when discharging it's calculating the time to the SoC configured in the config file

## v1.0.2
* Added: Timeout in order to disconnect the battery, if no new MQTT message is received after x seconds (configurable in `config.ini`)
Expand Down
10 changes: 5 additions & 5 deletions dbus-mqtt-battery/dbus-mqtt-battery.py
Original file line number Diff line number Diff line change
Expand Up @@ -391,16 +391,16 @@ def on_message(client, userdata, msg):
battery_dict['/TimeToGo']['value'] = 60 * 60 * 24 * 30

if 'Voltages' in jsonpayload and len(jsonpayload['Voltages']) > 0:
if 'MinVoltageCellId' not in jsonpayload['System']:
if 'System' not in jsonpayload or 'MinVoltageCellId' not in jsonpayload['System']:
battery_dict['/System/MinVoltageCellId']['value'] = min(jsonpayload['Voltages'], key=jsonpayload['Voltages'].get)

if 'MinCellVoltage' not in jsonpayload['System']:
if 'System' not in jsonpayload or 'MinCellVoltage' not in jsonpayload['System']:
battery_dict['/System/MinCellVoltage']['value'] = min(jsonpayload['Voltages'].values())

if 'MaxVoltageCellId' not in jsonpayload['System']:
if 'System' not in jsonpayload or 'MaxVoltageCellId' not in jsonpayload['System']:
battery_dict['/System/MaxVoltageCellId']['value'] = max(jsonpayload['Voltages'], key=jsonpayload['Voltages'].get)

if 'MaxCellVoltage' not in jsonpayload['System']:
if 'System' not in jsonpayload or 'MaxCellVoltage' not in jsonpayload['System']:
battery_dict['/System/MaxCellVoltage']['value'] = max(jsonpayload['Voltages'].values())

if 'Sum' not in jsonpayload['Voltages']:
Expand Down Expand Up @@ -460,7 +460,7 @@ def __init__(
self._dbusservice.add_path('/ProductId', 0xFFFF)
self._dbusservice.add_path('/ProductName', productname)
self._dbusservice.add_path('/CustomName', customname)
self._dbusservice.add_path('/FirmwareVersion', '1.0.3')
self._dbusservice.add_path('/FirmwareVersion', '1.0.4')
# self._dbusservice.add_path('/HardwareVersion', '')
self._dbusservice.add_path('/Connected', 1)

Expand Down

0 comments on commit cd1bda7

Please sign in to comment.