Skip to content

Commit

Permalink
fix issue with ruuvi tags
Browse files Browse the repository at this point in the history
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
  • Loading branch information
mr-manuel committed Nov 28, 2023
1 parent c548092 commit 0e6dbd8
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 3 deletions.
6 changes: 4 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`:

Expand Down
27 changes: 26 additions & 1 deletion etc/dbus-serialbattery/dbushelper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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": {
Expand Down Expand Up @@ -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)

Expand Down

0 comments on commit 0e6dbd8

Please sign in to comment.