From 3cdf3dbb48a126d34f207a1b3c32d61b3f6d35a0 Mon Sep 17 00:00:00 2001 From: Sean Stoops Date: Thu, 21 Mar 2024 15:52:29 -0700 Subject: [PATCH] Added Renogy.unique_identifier method to use serial number to eliminate multi-battery conflicts --- etc/dbus-serialbattery/bms/renogy.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/etc/dbus-serialbattery/bms/renogy.py b/etc/dbus-serialbattery/bms/renogy.py index a1a94628..f4ee3aab 100644 --- a/etc/dbus-serialbattery/bms/renogy.py +++ b/etc/dbus-serialbattery/bms/renogy.py @@ -41,6 +41,10 @@ def __init__(self, port, baud, address): ) # BMS warning and protection config + + def unique_identifier(self) -> str: + return self.serial_number + def test_connection(self): # call a function that will connect to the battery, send a command and retrieve the result. # The result or call should be unique to this BMS. Battery name or version, etc. @@ -125,6 +129,9 @@ def read_gen_data(self): capacity = self.read_serial_data_renogy(self.command_capacity) self.capacity = unpack(">L", capacity)[0] / 1000.0 + serial_number = self.read_serial_data_renogy(self.command_serial_number) + self.serial_number = unpack("16s", serial_number)[0].decode("utf-8") + return True def read_soc_data(self):