diff --git a/CHANGELOG.md b/CHANGELOG.md index 0520079..a2fe08b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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`) diff --git a/dbus-mqtt-battery/dbus-mqtt-battery.py b/dbus-mqtt-battery/dbus-mqtt-battery.py index dc2ef5e..c02be77 100644 --- a/dbus-mqtt-battery/dbus-mqtt-battery.py +++ b/dbus-mqtt-battery/dbus-mqtt-battery.py @@ -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']: @@ -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)