Lots of fixes, first working version, some stats missing

This commit is contained in:
Carsten Schmiemann 2023-05-21 04:01:39 +02:00
parent 9ade6ed80a
commit 0c78f7d9b1
2 changed files with 136 additions and 63 deletions

View file

@ -44,6 +44,14 @@ class BatriumBattery(can.Listener):
self.TimeToFull = 0 self.TimeToFull = 0
self.AhToEmpty = 0 self.AhToEmpty = 0
self.AhToFull = 0 self.AhToFull = 0
self.NumberInBypass = 0
self.alarm_high_temperature = 0
self.alarm_high_voltage = 0
self.alarm_low_temperature = 0
self.alarm_low_voltage = 0
self.alarm_low_soc = 0
self.alarm_high_charge_current = 0
self.alarm_high_discharge_current = 0
self._ci = can.interface.Bus(channel=connection, bustype='socketcan') self._ci = can.interface.Bus(channel=connection, bustype='socketcan')
@ -64,13 +72,6 @@ class BatriumBattery(can.Listener):
elif msg.arbitration_id == 0x00111500: elif msg.arbitration_id == 0x00111500:
logging.info("Found Batrium BMS on %s" % connection) logging.info("Found Batrium BMS on %s" % connection)
self.soc = (msg.data[0] * 0.5) - 5
self.voltage = ((msg.data[3] * 256) + msg.data[2]) * 0.01
self.current = (struct.unpack('>f', bytearray([msg.data[7], msg.data[6], msg.data[5], msg.data[4]])))[0] * 0.001
self.temperature = msg.data[1] - 40
logging.debug("SOC: %2d, I: %2.2fA, U: %2.2fV, T:%2.1fC" % (self.soc, self.current, self.voltage, self.temperature))
found = True found = True
break; break;
@ -91,6 +92,26 @@ class BatriumBattery(can.Listener):
logging.debug("Ah to Empty: %2.2f", self.AhToEmpty) logging.debug("Ah to Empty: %2.2f", self.AhToEmpty)
logging.debug("Capacity: %2.2f", self.capacity) logging.debug("Capacity: %2.2f", self.capacity)
elif msg.arbitration_id == 0x00140100:
self.alarm_high_temperature = (msg.data[2] >> 3) & 1
logging.debug("High Temp Alarm: %d", self.alarm_high_temperature)
self.alarm_high_voltage = (msg.data[2] >> 1) & 1
logging.debug("High Voltage Alarm: %d", self.alarm_high_voltage)
self.alarm_low_temperature = (msg.data[2] >> 2) & 1
logging.debug("Low Temperature Alarm: %d", self.alarm_low_temperature)
self.alarm_low_voltage = (msg.data[2] >> 0) & 1
logging.debug("Low Voltage Alarm: %d", self.alarm_low_voltage)
#self.alarm_low_soc = (msg.data[7] >> 2) & 1
logging.debug("Low SOC Alarm: %d", self.alarm_low_soc)
self.alarm_high_charge_current = (msg.data[3] >> 3) & 1
logging.debug("High Charge Current Alarm: %d", self.alarm_high_charge_current)
self.alarm_high_discharge_current = (msg.data[3] >> 4) & 1
logging.debug("High Discharge Current Alarm: %d", self.alarm_high_discharge_current)
elif msg.arbitration_id == 0x00111300:
self.NumberInBypass = msg.data[6]
logging.debug("Cell number in bypass: %d", self.NumberInBypass)
elif msg.arbitration_id == 0x00111800: elif msg.arbitration_id == 0x00111800:
self.TimeToEmpty = ((msg.data[5] * 256) + msg.data[4]) self.TimeToEmpty = ((msg.data[5] * 256) + msg.data[4])
logging.debug("Time to empty: %dmin", self.TimeToEmpty) logging.debug("Time to empty: %dmin", self.TimeToEmpty)
@ -113,8 +134,8 @@ class BatriumBattery(can.Listener):
elif msg.arbitration_id == 0x00111200: elif msg.arbitration_id == 0x00111200:
self.minCellTemperature = msg.data[0] - 40 self.minCellTemperature = msg.data[0] - 40
self.maxCellTemperature = msg.data[1] - 40 self.maxCellTemperature = msg.data[1] - 40
self.minCellTemperatureId = msg.data[4] self.minCellTemperatureId = msg.data[2]
self.maxCellTemperatureId = msg.data[5] self.maxCellTemperatureId = msg.data[3]
logging.debug("MinCellTemp: %d (ID: %d), MaxCellTemp: %d (ID: %d)", self.minCellTemperature, self.minCellTemperatureId, self.maxCellTemperature, self.maxCellTemperatureId) logging.debug("MinCellTemp: %d (ID: %d), MaxCellTemp: %d (ID: %d)", self.minCellTemperature, self.minCellTemperatureId, self.maxCellTemperature, self.maxCellTemperatureId)
elif msg.arbitration_id == 0x00111100: elif msg.arbitration_id == 0x00111100:
@ -132,12 +153,12 @@ class BatriumBattery(can.Listener):
self.cellTemperatures[cell_id] = msg.data[4] - 40 self.cellTemperatures[cell_id] = msg.data[4] - 40
self.cellBypassTemperatures[cell_id] = msg.data[5] - 40 self.cellBypassTemperatures[cell_id] = msg.data[5] - 40
self.cellBypassPWM[cell_id] = msg.data[6] self.cellBypassPWM[cell_id] = msg.data[6]
self.numberOfModules = len(self.cellVoltages_min.keys())
def prnt(self): def prnt(self):
print("SOC: %2d, I: %2.2fA, U: %2.2fV, T:%2.1fC" % (self.soc, self.current, self.voltage, self.maxCellTemperature)) print("SOC: %2d, I: %2.2fA, U: %2.2fV, T:%2.1fC" % (self.soc, self.current, self.voltage, self.maxCellTemperature))
print("MinCellVolt: %1.2f, MaxCellVolt: %1.2f CellVoltDelta: %1.2f" % (self.minCellVoltage, self.maxCellVoltage, self.maxCellVoltage-self.minCellVoltage)) print("MinCellVolt: %1.2f, MaxCellVolt: %1.2f CellVoltDelta: %1.2f" % (self.minCellVoltage, self.maxCellVoltage, self.maxCellVoltage-self.minCellVoltage))
print("MaxChargeCurrent (CCL): %4.1f A MaxChargeVoltage (CVL): %2.2f V" % (self.maxChargeCurrent, self.maxChargeVoltage)) print("MaxChargeCurrent (CCL): %4.1f A MaxChargeVoltage (CVL): %2.2f V" % (self.maxChargeCurrent, self.maxChargeVoltage))
self.numberOfModules = len(self.cellVoltages_min.keys())
print("Number of modules found: %1.0f" % (self.numberOfModules)) print("Number of modules found: %1.0f" % (self.numberOfModules))
# === All code below is to simply run it from the commandline for debugging purposes === # === All code below is to simply run it from the commandline for debugging purposes ===

View file

@ -41,6 +41,7 @@ class DbusBatteryService:
self.dailyResetDone = 0 self.dailyResetDone = 0
self.lastUpdated = 0 self.lastUpdated = 0
self._bat = BatriumBattery(connection=connection) self._bat = BatriumBattery(connection=connection)
self.notifier = can.Notifier(self._bat._ci, [self._bat])
try: try:
self._dbusservice = VeDbusService(servicename+'.socketcan_'+connection+'_di'+str(deviceinstance)) self._dbusservice = VeDbusService(servicename+'.socketcan_'+connection+'_di'+str(deviceinstance))
@ -54,44 +55,41 @@ class DbusBatteryService:
# Create the mandatory objects # Create the mandatory objects
self._dbusservice.add_path('/DeviceInstance', deviceinstance) self._dbusservice.add_path('/DeviceInstance', deviceinstance)
self._dbusservice.add_path('/ProductId', 0) self._dbusservice.add_path('/ProductId', 0xB038)
self._dbusservice.add_path('/ProductName', productname) self._dbusservice.add_path('/ProductName', productname)
self._dbusservice.add_path('/FirmwareVersion', 'unknown') self._dbusservice.add_path('/FirmwareVersion', 'unknown')
self._dbusservice.add_path('/HardwareVersion', 'unknown') self._dbusservice.add_path('/HardwareVersion', 'unknown')
self._dbusservice.add_path('/Connected', 0) self._dbusservice.add_path('/Connected', 0)
# Create battery specific objects # Create battery specific objects
self._dbusservice.add_path('/Status', 0) self._dbusservice.add_path('/Status', None, writeable=True)
self._dbusservice.add_path('/Soh', 100) self._dbusservice.add_path('/Soh', 100)
self._dbusservice.add_path('/Capacity', 0) #self._dbusservice.add_path('/Capacity', None, writeable=True)
self._dbusservice.add_path('/InstalledCapacity', 0) #self._dbusservice.add_path('/InstalledCapacity', None, writeable=True)
self._dbusservice.add_path('/Dc/0/Temperature', 20) self._dbusservice.add_path('/Dc/0/Temperature', None, writeable=True)
self._dbusservice.add_path('/Info/MaxChargeCurrent', 5) self._dbusservice.add_path('/Info/BatteryLowVoltage', None, writeable=True)
self._dbusservice.add_path('/Info/MaxDischargeCurrent', 5) self._dbusservice.add_path('/Alarms/CellImbalance', None, writeable=True)
self._dbusservice.add_path('/Info/MaxChargeVoltage', 0) self._dbusservice.add_path('/Alarms/LowVoltage', None, writeable=True)
self._dbusservice.add_path('/Info/BatteryLowVoltage', 48.0) self._dbusservice.add_path('/Alarms/HighVoltage', None, writeable=True)
self._dbusservice.add_path('/Alarms/CellImbalance', 0) self._dbusservice.add_path('/Alarms/HighDischargeCurrent', None, writeable=True)
self._dbusservice.add_path('/Alarms/LowVoltage', 0) self._dbusservice.add_path('/Alarms/HighChargeCurrent', None, writeable=True)
self._dbusservice.add_path('/Alarms/HighVoltage', 0) self._dbusservice.add_path('/Alarms/LowSoc', None, writeable=True)
self._dbusservice.add_path('/Alarms/HighDischargeCurrent', 0) self._dbusservice.add_path('/Alarms/LowTemperature', None, writeable=True)
self._dbusservice.add_path('/Alarms/HighChargeCurrent', 0) self._dbusservice.add_path('/Alarms/HighTemperature', None, writeable=True)
self._dbusservice.add_path('/Alarms/LowSoc', 0) self._dbusservice.add_path('/Balancing', None, writeable=True)
self._dbusservice.add_path('/Alarms/LowTemperature', 0)
self._dbusservice.add_path('/Alarms/HighTemperature', 0)
self._dbusservice.add_path('/Balancing', 0)
self._dbusservice.add_path('/System/HasTemperature', 1) self._dbusservice.add_path('/System/HasTemperature', 1)
self._dbusservice.add_path('/System/NrOfBatteries', 1) self._dbusservice.add_path('/System/NrOfBatteries', 1)
self._dbusservice.add_path('/System/NrOfModulesOnline', 1) self._dbusservice.add_path('/System/NrOfModulesOnline', None, writeable=True)
self._dbusservice.add_path('/System/NrOfModulesOffline', 0) self._dbusservice.add_path('/System/NrOfModulesOffline', 0)
self._dbusservice.add_path('/System/NrOfModulesBlockingDischarge', 0) self._dbusservice.add_path('/System/NrOfModulesBlockingDischarge', 0)
self._dbusservice.add_path('/System/NrOfModulesBlockingCharge', 0) self._dbusservice.add_path('/System/NrOfModulesBlockingCharge', 0)
self._dbusservice.add_path('/System/NrOfBatteriesBalancing', 0) self._dbusservice.add_path('/System/NrOfBatteriesBalancing', None, writeable=True)
self._dbusservice.add_path('/System/BatteriesParallel', 1) self._dbusservice.add_path('/System/BatteriesSeries', None, writeable=True)
self._dbusservice.add_path('/System/BatteriesSeries', 1) self._dbusservice.add_path('/System/MinVoltageCellId', None, writeable=True)
self._dbusservice.add_path('/System/NrOfCellsPerBattery', 4) self._dbusservice.add_path('/System/MaxVoltageCellId', None, writeable=True)
self._dbusservice.add_path('/System/MinVoltageCellId', 0) self._dbusservice.add_path("/System/MinTemperatureCellId", None, writeable=True)
self._dbusservice.add_path('/System/MaxVoltageCellId', 0) self._dbusservice.add_path("/System/MaxTemperatureCellId", None, writeable=True)
self._dbusservice.add_path('/System/MinCellTemperature', 10.0) #self._dbusservice.add_path('/System/MinCellTemperature', None, writeable=True)
self._dbusservice.add_path('/System/MaxCellTemperature', 10.0) #self._dbusservice.add_path('/System/MaxCellTemperature', None, writeable=True)
self._settings = SettingsDevice( self._settings = SettingsDevice(
bus=dbus.SystemBus() if (platform.machine() == 'armv7l') else dbus.SessionBus(), bus=dbus.SystemBus() if (platform.machine() == 'armv7l') else dbus.SessionBus(),
@ -99,18 +97,18 @@ class DbusBatteryService:
'AvgDischarge': ['/Settings/Batrium/AvgerageDischarge', 0.0,0,0], 'AvgDischarge': ['/Settings/Batrium/AvgerageDischarge', 0.0,0,0],
'TotalAhDrawn': ['/Settings/Batrium/TotalAhDrawn', 0.0,0,0], 'TotalAhDrawn': ['/Settings/Batrium/TotalAhDrawn', 0.0,0,0],
'TimeLastFull': ['/Settings/Batrium/TimeLastFull', 0.0 ,0,0], 'TimeLastFull': ['/Settings/Batrium/TimeLastFull', 0.0 ,0,0],
'MinCellVoltage': ['/Settings/Batrium/MinCellVoltage', 4.0,2.0,4.2], 'MinCellVoltage': ['/Settings/Batrium/MinCellVoltage', 0.0,0.0,0.0],
'MaxCellVoltage': ['/Settings/Batrium/MaxCellVoltage', 2.0,2.0,4.2], 'MaxCellVoltage': ['/Settings/Batrium/MaxCellVoltage', 0.0,0.0,0.0],
'interval': ['/Settings/Batrium/Interval', 10, 10, 10] 'interval': ['/Settings/Batrium/Interval', 200, 200, 200]
}, },
eventCallback=handle_changed_setting) eventCallback=handle_changed_setting)
self._summeditems = { self._summeditems = {
'/System/MaxCellVoltage': {'gettext': '%.2F V'}, '/System/MaxCellVoltage': {'gettext': '%.3F V'},
'/System/MinCellVoltage': {'gettext': '%.2F V'}, '/System/MinCellVoltage': {'gettext': '%.3F V'},
'/Dc/0/Voltage': {'gettext': '%.2F V'}, '/Dc/0/Voltage': {'gettext': '%.2F V'},
'/Dc/0/Current': {'gettext': '%.1F A'}, '/Dc/0/Current': {'gettext': '%.2F A'},
'/Dc/0/Power': {'gettext': '%.0F W'}, '/Dc/0/Power': {'gettext': '%.0F W'},
'/Soc': {'gettext': '%.0F %%'}, '/Soc': {'gettext': '%.0F %%'},
'/History/TotalAhDrawn': {'gettext': '%.0F Ah'}, '/History/TotalAhDrawn': {'gettext': '%.0F Ah'},
@ -118,7 +116,14 @@ class DbusBatteryService:
'/History/ChargedEnergy': {'gettext': '%.2F kWh'}, '/History/ChargedEnergy': {'gettext': '%.2F kWh'},
'/History/AverageDischarge': {'gettext': '%.2F kWh'}, '/History/AverageDischarge': {'gettext': '%.2F kWh'},
'/TimeToGo': {'gettext': '%.0F s'}, '/TimeToGo': {'gettext': '%.0F s'},
'/ConsumedAmphours': {'gettext': '%.1F Ah'} '/ConsumedAmphours': {'gettext': '%.1F Ah'},
'/System/MinCellTemperature': {'gettext': '%.1F °C'},
'/System/MaxCellTemperature': {'gettext': '%.1F °C'},
'/Capacity': {'gettext': '%.1F Ah'},
'/InstalledCapacity': {'gettext': '%.1F Ah'},
'/Info/MaxChargeVoltage': {'gettext': '%.1F V'},
'/Info/MaxChargeCurrent': {'gettext': '%.1F A'},
'/Info/MaxDischargeCurrent': {'gettext': '%.1F A'}
} }
for path in self._summeditems.keys(): for path in self._summeditems.keys():
@ -129,7 +134,7 @@ class DbusBatteryService:
self._dbusservice.add_path('/History/TimeSinceLastFullCharge', 0) self._dbusservice.add_path('/History/TimeSinceLastFullCharge', 0)
self._dbusservice.add_path('/History/MinCellVoltage', self._settings['MinCellVoltage']) self._dbusservice.add_path('/History/MinCellVoltage', self._settings['MinCellVoltage'])
self._dbusservice.add_path('/History/MaxCellVoltage', self._settings['MaxCellVoltage']) self._dbusservice.add_path('/History/MaxCellVoltage', self._settings['MaxCellVoltage'])
self._dbusservice['/ConsumedAmphours'] = 0 self._dbusservice['/ConsumedAmphours'] = self._bat.AhToEmpty
logging.info("History cell voltage min: %.3f, max: %.3f, totalAhDrawn: %d", logging.info("History cell voltage min: %.3f, max: %.3f, totalAhDrawn: %d",
self._settings['MinCellVoltage'], self._settings['MaxCellVoltage'], self._settings['TotalAhDrawn']) self._settings['MinCellVoltage'], self._settings['MaxCellVoltage'], self._settings['TotalAhDrawn'])
@ -170,36 +175,65 @@ class DbusBatteryService:
def _update(self): def _update(self):
logging.debug("Update") #logging.debug("Update CAN %d, Time Now: %d", self._bat.updated, self.lastUpdated)
if (self._bat.updated != -1 and self.lastUpdated == 0) or ((self._bat.updated - self.lastUpdated) < 1000): time = datetime.now()
self.lastUpdated = self._bat.updated self.lastUpdated = time.timestamp()
if self._bat.alarm_high_temperature:
self._dbusservice['/Alarms/HighTemperature'] = 2
else:
self._dbusservice['/Alarms/HighTemperature'] = 0
if self._bat.alarm_low_temperature:
self._dbusservice['/Alarms/LowTemperature'] = 2
else:
self._dbusservice['/Alarms/LowTemperature'] = 0
if self._bat.alarm_low_voltage:
self._dbusservice['/Alarms/LowVoltage'] = 2
else:
self._dbusservice['/Alarms/LowVoltage'] = 0
if self._bat.alarm_high_voltage:
self._dbusservice['/Alarms/HighVoltage'] = 2
else:
self._dbusservice['/Alarms/HighVoltage'] = 0
if self._bat.alarm_high_charge_current:
self._dbusservice['/Alarms/HighChargeCurrent'] = 2
else:
self._dbusservice['/Alarms/HighChargeCurrent'] = 0
if self._bat.alarm_high_discharge_current:
self._dbusservice['/Alarms/HighDischargeCurrent'] = 2
else:
self._dbusservice['/Alarms/HighDischargeCurrent'] = 0
if self._bat.alarm_low_soc:
self._dbusservice['/Alarms/LowSoc'] = 2
else:
self._dbusservice['/Alarms/LowSoc'] = 0
if (self._bat.updated != -1 and self.lastUpdated == 0) or ((self.lastUpdated - self._bat.updated) < 10):
self._dbusservice['/Connected'] = 1 self._dbusservice['/Connected'] = 1
else: else:
self._dbusservice['/Connected'] = 0 self._dbusservice['/Connected'] = 0
self._dbusservice['/Soc'] = self._bat.soc
if self._bat.NumberInBypass != 0:
self._dbusservice['/Balancing'] = 1
else:
self._dbusservice['/Balancing'] = 0
self._dbusservice['/InstalledCapacity'] = self._bat.capacity self._dbusservice['/InstalledCapacity'] = self._bat.capacity
self._dbusservice['/Capacity'] = self._bat.capacity
self._dbusservice['/Dc/0/Current'] = self._bat.current self._dbusservice['/Dc/0/Current'] = self._bat.current
self._dbusservice['/Dc/0/Voltage'] = self._bat.voltage self._dbusservice['/Dc/0/Voltage'] = self._bat.voltage
power = self._bat.voltage * self._bat.current power = self._bat.voltage * self._bat.current
self._dbusservice['/Dc/0/Power'] = power self._dbusservice['/Dc/0/Power'] = power
self._dbusservice['/Dc/0/Temperature'] = self._bat.maxCellTemperature self._dbusservice['/Dc/0/Temperature'] = self._bat.maxCellTemperature
self._dbusservice['/System/MaxVoltageCellId'] = self._bat.maxCellVoltageId
self._dbusservice['/System/MinVoltageCellId'] = self._bat.minCellVoltageId
self._dbusservice['/System/MaxCellVoltage'] = self._bat.maxCellVoltage
if (self._bat.maxCellVoltage > self._dbusservice['/History/MaxCellVoltage'] ):
self._dbusservice['/History/MaxCellVoltage'] = self._bat.maxCellVoltage
logging.info("New maximum cell voltage: %f", self._bat.maxCellVoltage)
self._dbusservice['/System/MinCellVoltage'] = self._bat.minCellVoltage
if (0 < self._bat.minCellVoltage < self._dbusservice['/History/MinCellVoltage'] ):
self._dbusservice['/History/MinCellVoltage'] = self._bat.minCellVoltage
logging.info("New minimum cell voltage: %f", self._bat.minCellVoltage)
self._dbusservice['/System/MinCellTemperature'] = self._bat.minCellTemperature
self._dbusservice['/System/MaxCellTemperature'] = self._bat.maxCellTemperature
self._dbusservice['/Info/MaxChargeCurrent'] = self._bat.maxChargeCurrent self._dbusservice['/Info/MaxChargeCurrent'] = self._bat.maxChargeCurrent
self._dbusservice['/Info/MaxDischargeCurrent'] = self._bat.maxDischargeCurrent self._dbusservice['/Info/MaxDischargeCurrent'] = self._bat.maxDischargeCurrent
self._dbusservice['/Info/MaxChargeVoltage'] = self._bat.maxChargeVoltage
if self._bat.maxChargeVoltage != 0:
self._dbusservice['/Info/MaxChargeVoltage'] = self._bat.maxChargeVoltage
self._dbusservice['/System/NrOfModulesOnline'] = self._bat.numberOfModules self._dbusservice['/System/NrOfModulesOnline'] = self._bat.numberOfModules
self._dbusservice['/System/BatteriesSeries'] = self._bat.numberOfModules
#update energy statistics daily at 6:00, #update energy statistics daily at 6:00,
if datetime.now().hour == 6 and datetime.now().minute == 0 and datetime.now().day != self.dailyResetDone : if datetime.now().hour == 6 and datetime.now().minute == 0 and datetime.now().day != self.dailyResetDone :
@ -208,12 +242,30 @@ class DbusBatteryService:
now = datetime.now().time() now = datetime.now().time()
if now.minute != self.minUpdateDone: if now.minute != self.minUpdateDone:
self.minUpdateDone = now.minute self.minUpdateDone = now.minute
self._dbusservice['/System/MinCellTemperature'] = self._bat.minCellTemperature
self._dbusservice['/System/MaxCellTemperature'] = self._bat.maxCellTemperature
self._dbusservice['/System/MinTemperatureCellId'] = self._bat.minCellTemperatureId
self._dbusservice['/System/MaxTemperatureCellId'] = self._bat.maxCellTemperatureId
self._dbusservice['/System/MaxCellVoltage'] = self._bat.maxCellVoltage
if (self._bat.maxCellVoltage > self._dbusservice['/History/MaxCellVoltage'] ):
self._dbusservice['/History/MaxCellVoltage'] = self._bat.maxCellVoltage
logging.info("New maximum cell voltage: %f", self._bat.maxCellVoltage)
self._dbusservice['/System/MinCellVoltage'] = self._bat.minCellVoltage
if (0 < self._bat.minCellVoltage < self._dbusservice['/History/MinCellVoltage'] ):
self._dbusservice['/History/MinCellVoltage'] = self._bat.minCellVoltage
logging.info("New minimum cell voltage: %f", self._bat.minCellVoltage)
self._dbusservice['/System/MaxVoltageCellId'] = self._bat.maxCellVoltageId
self._dbusservice['/System/MinVoltageCellId'] = self._bat.minCellVoltageId
if self._bat.current > 0: if self._bat.current > 0:
#charging #charging
self._dbusservice['/TimeToGo'] = self._bat.TimeToFull self._dbusservice['/TimeToGo'] = self._bat.TimeToFull * 60
else : else :
#discharging #discharging
self._dbusservice['/TimeToGo'] = self._bat.TimeToEmpty self._dbusservice['/TimeToGo'] = self._bat.TimeToEmpty * 60
self._safe_history() self._safe_history()