From 3df092bf4d7a9e3ad4deb1bde603198477f7507b Mon Sep 17 00:00:00 2001 From: Sven ten Raa Date: Mon, 29 Apr 2024 10:30:00 +0200 Subject: [PATCH] Add more debug logging and cleanup sensor device registration --- custom_components/victron/binary_sensor.py | 2 +- custom_components/victron/button.py | 2 +- custom_components/victron/number.py | 2 +- custom_components/victron/select.py | 2 +- custom_components/victron/sensor.py | 6 +++--- custom_components/victron/switch.py | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/custom_components/victron/binary_sensor.py b/custom_components/victron/binary_sensor.py index 56542f4..671d70d 100644 --- a/custom_components/victron/binary_sensor.py +++ b/custom_components/victron/binary_sensor.py @@ -83,7 +83,7 @@ def __init__(self, coordinator: victronEnergyDeviceUpdateCoordinator, descriptio self._attr_name = f"{description.name}" #VE.CAN device zero is present under unit 100. This seperates non system / settings entities into the seperate can device - if description.slave == 100 and not description.key.startswith(("settings", "system")) : + if description.slave == 100 and not description.key.startswith("settings", "system") : actual_id = 0 else: actual_id = description.slave diff --git a/custom_components/victron/button.py b/custom_components/victron/button.py index e353bd9..84233ce 100644 --- a/custom_components/victron/button.py +++ b/custom_components/victron/button.py @@ -80,7 +80,7 @@ def __init__(self, coordinator: victronEnergyDeviceUpdateCoordinator, descriptio self._attr_name = f"{description.name}" #VE.CAN device zero is present under unit 100. This seperates non system / settings entities into the seperate can device - if description.slave == 100 and not description.key.startswith(("settings", "system")) : + if description.slave == 100 and not description.key.startswith("settings", "system") : actual_id = 0 else: actual_id = description.slave diff --git a/custom_components/victron/number.py b/custom_components/victron/number.py index 28ca6cd..e0cb147 100644 --- a/custom_components/victron/number.py +++ b/custom_components/victron/number.py @@ -170,7 +170,7 @@ def __init__(self, coordinator: victronEnergyDeviceUpdateCoordinator, descriptio self.data_key = str(self.description.slave) + "." + str(self.description.key) #VE.CAN device zero is present under unit 100. This seperates non system / settings entities into the seperate can device - if description.slave == 100 and not description.key.startswith(("settings", "system")) : + if description.slave == 100 and not description.key.startswith("settings", "system") : actual_id = 0 else: actual_id = description.slave diff --git a/custom_components/victron/select.py b/custom_components/victron/select.py index f23b912..e867905 100644 --- a/custom_components/victron/select.py +++ b/custom_components/victron/select.py @@ -84,7 +84,7 @@ def __init__(self, hass: HomeAssistant, coordinator: victronEnergyDeviceUpdateCo self._attr_name = f"{description.name}" #VE.CAN device zero is present under unit 100. This seperates non system / settings entities into the seperate can device - if description.slave == 100 and not description.key.startswith(("settings", "system")) : + if description.slave == 100 and not description.key.startswith("settings", "system") : actual_id = 0 else: actual_id = description.slave diff --git a/custom_components/victron/sensor.py b/custom_components/victron/sensor.py index 70b5ae8..491be78 100644 --- a/custom_components/victron/sensor.py +++ b/custom_components/victron/sensor.py @@ -52,8 +52,8 @@ async def async_setup_entry( for slave, registerLedger in register_set.items(): for name in registerLedger: for register_name, registerInfo in register_info_dict[name].items(): - # _LOGGER.debug("unit == " + str(slave) + " registerLedger == " + str(registerLedger) + " registerInfo ") - # _LOGGER.debug(str(registerInfo.slave)) + _LOGGER.debug("unit == " + str(slave) + " registerLedger == " + str(registerLedger) + " registerInfo ") + _LOGGER.debug(str(registerInfo.slave)) if config_entry.options[CONF_ADVANCED_OPTIONS]: if not isinstance(registerInfo.entityType, ReadEntityType) or isinstance(registerInfo.entityType, BoolReadEntityType): continue @@ -131,7 +131,7 @@ def __init__(self, coordinator: victronEnergyDeviceUpdateCoordinator, descriptio self.entity_type = description.entity_type #VE.CAN device zero is present under unit 100. This seperates non system / settings entities into the seperate can device - if description.slave == 100 and not description.key.startswith(("settings", "system")) : + if description.slave == 100 and not description.key.startswith("settings", "system") : actual_id = 0 else: actual_id = description.slave diff --git a/custom_components/victron/switch.py b/custom_components/victron/switch.py index 40981dc..7f5c5df 100644 --- a/custom_components/victron/switch.py +++ b/custom_components/victron/switch.py @@ -78,7 +78,7 @@ def __init__(self, hass: HomeAssistant, coordinator: victronEnergyDeviceUpdateCo self.data_key = str(self.description.slave) + "." + str(self.description.key) #VE.CAN device zero is present under unit 100. This seperates non system / settings entities into the seperate can device - if description.slave == 100 and not description.key.startswith(("settings", "system")) : + if description.slave == 100 and not description.key.startswith("settings", "system") : actual_id = 0 else: actual_id = description.slave