From 0e6dbd850438a35c4bea68159a91997cc697d0b5 Mon Sep 17 00:00:00 2001 From: Manuel Date: Tue, 28 Nov 2023 19:06:28 +0100 Subject: [PATCH] fix issue with ruuvi tags When there are hundreds of unused ruuvi tags in the settings list that where added because thei where nearby the driver does not start correctly. These stale entries are disabled on the driver startup. The issue was already filed to Victron developers --- CHANGELOG.md | 6 ++++-- etc/dbus-serialbattery/dbushelper.py | 27 ++++++++++++++++++++++++++- 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 969af800..300e1a32 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,9 +6,11 @@ ## Breaking changes -* Driver version greater or equal to `v1.0.20231126beta` +* Driver version greater or equal to `v1.0.20231128beta` - The custom name is not saved to the config file anymore, but to the dbus service com.victronenergy.settings. You have to re-enter it once. + * The custom name is not saved to the config file anymore, but to the dbus service com.victronenergy.settings. You have to re-enter it once. + + * If you selected a specific device in `Settings -> System setup -> Battery monitor` and/or `Settings -> DVCC -> Controlling BMS` you have to reselect it. * Driver version greater or equal to `v1.0.20230629beta` and smaller or equal to `v1.0.20230926beta`: diff --git a/etc/dbus-serialbattery/dbushelper.py b/etc/dbus-serialbattery/dbushelper.py index 66fd47d0..e65f515d 100644 --- a/etc/dbus-serialbattery/dbushelper.py +++ b/etc/dbus-serialbattery/dbushelper.py @@ -65,6 +65,7 @@ def setup_instance(self): # bms_id = self.battery.production if self.battery.production is not None else \ # self.battery.port[self.battery.port.rfind('/') + 1:] # bms_id = self.battery.port[self.battery.port.rfind("/") + 1 :] + logger.debug("setup_instance(): start") custom_name = self.battery.custom_name() device_instance = "1" @@ -76,11 +77,15 @@ def setup_instance(self): self.settings = SettingsDevice( get_bus(), self.EMPTY_DICT, self.handle_changed_setting ) + logger.debug("setup_instance(): SettingsDevice") # get all the settings from the dbus settings_from_dbus = self.getSettingsWithValues( - get_bus(), "com.victronenergy.settings", "/Settings/Devices" + get_bus(), + "com.victronenergy.settings", + "/Settings/Devices", ) + logger.debug("setup_instance(): getSettingsWithValues") # output: # { # "Settings": { @@ -209,6 +214,26 @@ def setup_instance(self): + f"Old entry. Delete result: {del_return}" ) + if "ruuvi" in key: + # check if Ruuvi tag is enabled, if not remove entry. + if ( + "Enabled" in value + and value["Enabled"] == "0" + and "ClassAndVrmInstance" not in value + ): + del_return = self.removeSetting( + get_bus(), + "com.victronenergy.settings", + "/Settings/Devices/" + key, + ["CustomName", "Enabled", "TemperatureType"], + ) + logger.info( + f"Remove /Settings/Devices/{key} from dbus. " + + f"Ruuvi tag was disabled and had no ClassAndVrmInstance. Delete result: {del_return}" + ) + + logger.debug("setup_instance(): for loop ended") + # create class and crm instance class_and_vrm_instance = "battery:" + str(device_instance)