From d491fd4d4aec9eb29907baedb03454b5daf295ad Mon Sep 17 00:00:00 2001 From: SeaSpotter Date: Sat, 13 Jun 2026 11:04:47 +0200 Subject: [PATCH 1/4] Fix update message --- packages/helpermodules/update_config.py | 116 ++++++++++++------------ 1 file changed, 57 insertions(+), 59 deletions(-) diff --git a/packages/helpermodules/update_config.py b/packages/helpermodules/update_config.py index 7a34baf412..b2403ba507 100644 --- a/packages/helpermodules/update_config.py +++ b/packages/helpermodules/update_config.py @@ -3198,66 +3198,64 @@ def upgrade(topic: str, payload) -> None: self._append_datastore_version(127) def upgrade_datastore_128(self) -> None: - """ - Consolidate 3 separate SMA battery modules (bat, bat_tesvolt, bat_smart_energy) - into single unified bat module with version field. - Maps old component types to new versioned structure: - - bat (with hybrid=True in inverter) -> bat with version:0 (hybrid) - - bat (with hybrid=False in inverter) -> bat with version:1 (sbs - standalone battery) - - bat_smart_energy -> bat with version:0 (hybrid) - - bat_tesvolt -> bat with version:2 (tesvolt) - """ - def upgrade_component(topic: str, payload) -> Optional[dict]: - if re.search(r"^openWB/system/device/[0-9]+/component/[0-9]+/config$", topic) is not None: - component = decode_payload(payload) - device_id = get_index(topic) - device_topic = f"openWB/system/device/{device_id}/config" - if device_topic not in self.all_received_topics: - return None - - device_config = decode_payload(self.all_received_topics[device_topic]) - if not str(device_config.get("type", "")).startswith("sma_sunny_boy"): - return None - - if component.get("type") == "bat_tesvolt": - component["type"] = "bat" - component["configuration"] = { - "version": 2, - "modbus_id": 25 - } - return {topic: component} - - elif component.get("type") == "bat_smart_energy": - component["type"] = "bat" - old_config = component.get("configuration", {}) - component["configuration"] = { - "version": 0, - "modbus_id": old_config.get("modbus_id", 3) - } - return {topic: component} - - elif component.get("type") == "bat": - is_hybrid = False - - for t, p in self.all_received_topics.items(): - if re.search(f"^openWB/system/device/{device_id}/component/[0-9]+/config$", t): - comp_check = decode_payload(p) - if comp_check.get("type") == "inverter": - is_hybrid = comp_check.get("configuration", {}).get("hybrid", False) - break - - old_config = component.get("configuration", {}) - - component["configuration"] = { - "version": 0 if is_hybrid else 1, - "modbus_id": old_config.get("modbus_id", 3) - } - return {topic: component} - - return None + """ + Consolidate 3 separate SMA battery modules (bat, bat_tesvolt, bat_smart_energy) + into single unified bat module with version field. + Maps old component types to new versioned structure: + - bat (with hybrid=True in inverter) -> bat with version:0 (hybrid) + - bat (with hybrid=False in inverter) -> bat with version:1 (sbs - standalone battery) + - bat_smart_energy -> bat with version:0 (hybrid) + - bat_tesvolt -> bat with version:2 (tesvolt) + """ + upgraded = [] + + def upgrade_component(topic: str, payload) -> Optional[dict]: + if re.search(r"^openWB/system/device/[0-9]+/component/[0-9]+/config$", topic) is not None: + component = decode_payload(payload) + device_id = get_index(topic) + device_topic = f"openWB/system/device/{device_id}/config" + if device_topic not in self.all_received_topics: + return None + device_config = decode_payload(self.all_received_topics[device_topic]) + if not str(device_config.get("type", "")).startswith("sma_sunny_boy"): + return None + if component.get("type") == "bat_tesvolt": + component["type"] = "bat" + component["configuration"] = { + "version": 2, + "modbus_id": 25 + } + upgraded.append(topic) + return {topic: component} + elif component.get("type") == "bat_smart_energy": + component["type"] = "bat" + old_config = component.get("configuration", {}) + component["configuration"] = { + "version": 0, + "modbus_id": old_config.get("modbus_id", 3) + } + upgraded.append(topic) + return {topic: component} + elif component.get("type") == "bat": + is_hybrid = False + for t, p in self.all_received_topics.items(): + if re.search(f"^openWB/system/device/{device_id}/component/[0-9]+/config$", t): + comp_check = decode_payload(p) + if comp_check.get("type") == "inverter": + is_hybrid = comp_check.get("configuration", {}).get("hybrid", False) + break + old_config = component.get("configuration", {}) + component["configuration"] = { + "version": 0 if is_hybrid else 1, + "modbus_id": old_config.get("modbus_id", 3) + } + upgraded.append(topic) + return {topic: component} + return None - self._loop_all_received_topics(upgrade_component) + self._loop_all_received_topics(upgrade_component) + if upgraded: pub_system_message( {}, "Die SMA Speicher-Module wurden erfolgreich zusammengeführt. " @@ -3265,4 +3263,4 @@ def upgrade_component(topic: str, payload) -> Optional[dict]: MessageType.INFO ) - self._append_datastore_version(128) + self._append_datastore_version(128) From 9aac889c3f2253fb5d9edb470335e5d7ac6cf9fb Mon Sep 17 00:00:00 2001 From: SeaSpotter Date: Sat, 13 Jun 2026 11:08:31 +0200 Subject: [PATCH 2/4] Fix update message --- packages/helpermodules/update_config.py | 132 ++++++++++++------------ 1 file changed, 66 insertions(+), 66 deletions(-) diff --git a/packages/helpermodules/update_config.py b/packages/helpermodules/update_config.py index b2403ba507..4a2d8605cd 100644 --- a/packages/helpermodules/update_config.py +++ b/packages/helpermodules/update_config.py @@ -3198,69 +3198,69 @@ def upgrade(topic: str, payload) -> None: self._append_datastore_version(127) def upgrade_datastore_128(self) -> None: - """ - Consolidate 3 separate SMA battery modules (bat, bat_tesvolt, bat_smart_energy) - into single unified bat module with version field. - Maps old component types to new versioned structure: - - bat (with hybrid=True in inverter) -> bat with version:0 (hybrid) - - bat (with hybrid=False in inverter) -> bat with version:1 (sbs - standalone battery) - - bat_smart_energy -> bat with version:0 (hybrid) - - bat_tesvolt -> bat with version:2 (tesvolt) - """ - upgraded = [] - - def upgrade_component(topic: str, payload) -> Optional[dict]: - if re.search(r"^openWB/system/device/[0-9]+/component/[0-9]+/config$", topic) is not None: - component = decode_payload(payload) - device_id = get_index(topic) - device_topic = f"openWB/system/device/{device_id}/config" - if device_topic not in self.all_received_topics: - return None - device_config = decode_payload(self.all_received_topics[device_topic]) - if not str(device_config.get("type", "")).startswith("sma_sunny_boy"): - return None - if component.get("type") == "bat_tesvolt": - component["type"] = "bat" - component["configuration"] = { - "version": 2, - "modbus_id": 25 - } - upgraded.append(topic) - return {topic: component} - elif component.get("type") == "bat_smart_energy": - component["type"] = "bat" - old_config = component.get("configuration", {}) - component["configuration"] = { - "version": 0, - "modbus_id": old_config.get("modbus_id", 3) - } - upgraded.append(topic) - return {topic: component} - elif component.get("type") == "bat": - is_hybrid = False - for t, p in self.all_received_topics.items(): - if re.search(f"^openWB/system/device/{device_id}/component/[0-9]+/config$", t): - comp_check = decode_payload(p) - if comp_check.get("type") == "inverter": - is_hybrid = comp_check.get("configuration", {}).get("hybrid", False) - break - old_config = component.get("configuration", {}) - component["configuration"] = { - "version": 0 if is_hybrid else 1, - "modbus_id": old_config.get("modbus_id", 3) - } - upgraded.append(topic) - return {topic: component} - return None - - self._loop_all_received_topics(upgrade_component) - - if upgraded: - pub_system_message( - {}, - "Die SMA Speicher-Module wurden erfolgreich zusammengeführt. " - "Deine bestehenden Einstellungen wurden automatisch übernommen.", - MessageType.INFO - ) - - self._append_datastore_version(128) + """ + Consolidate 3 separate SMA battery modules (bat, bat_tesvolt, bat_smart_energy) + into single unified bat module with version field. + Maps old component types to new versioned structure: + - bat (with hybrid=True in inverter) -> bat with version:0 (hybrid) + - bat (with hybrid=False in inverter) -> bat with version:1 (sbs - standalone battery) + - bat_smart_energy -> bat with version:0 (hybrid) + - bat_tesvolt -> bat with version:2 (tesvolt) + """ + upgraded = [] + + def upgrade_component(topic: str, payload) -> Optional[dict]: + if re.search(r"^openWB/system/device/[0-9]+/component/[0-9]+/config$", topic) is not None: + component = decode_payload(payload) + device_id = get_index(topic) + device_topic = f"openWB/system/device/{device_id}/config" + if device_topic not in self.all_received_topics: + return None + device_config = decode_payload(self.all_received_topics[device_topic]) + if not str(device_config.get("type", "")).startswith("sma_sunny_boy"): + return None + if component.get("type") == "bat_tesvolt": + component["type"] = "bat" + component["configuration"] = { + "version": 2, + "modbus_id": 25 + } + upgraded.append(topic) + return {topic: component} + elif component.get("type") == "bat_smart_energy": + component["type"] = "bat" + old_config = component.get("configuration", {}) + component["configuration"] = { + "version": 0, + "modbus_id": old_config.get("modbus_id", 3) + } + upgraded.append(topic) + return {topic: component} + elif component.get("type") == "bat": + is_hybrid = False + for t, p in self.all_received_topics.items(): + if re.search(f"^openWB/system/device/{device_id}/component/[0-9]+/config$", t): + comp_check = decode_payload(p) + if comp_check.get("type") == "inverter": + is_hybrid = comp_check.get("configuration", {}).get("hybrid", False) + break + old_config = component.get("configuration", {}) + component["configuration"] = { + "version": 0 if is_hybrid else 1, + "modbus_id": old_config.get("modbus_id", 3) + } + upgraded.append(topic) + return {topic: component} + return None + + self._loop_all_received_topics(upgrade_component) + + if upgraded: + pub_system_message( + {}, + "Die SMA Speicher-Module wurden erfolgreich zusammengeführt. " + "Deine bestehenden Einstellungen wurden automatisch übernommen.", + MessageType.INFO + ) + + self._append_datastore_version(128) From 05c69338a9433ed4d181ad0a91b3d5aeaf74f2a2 Mon Sep 17 00:00:00 2001 From: SeaSpotter Date: Sat, 13 Jun 2026 11:09:48 +0200 Subject: [PATCH 3/4] flake8 --- packages/helpermodules/update_config.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/helpermodules/update_config.py b/packages/helpermodules/update_config.py index 4a2d8605cd..57ec23a34d 100644 --- a/packages/helpermodules/update_config.py +++ b/packages/helpermodules/update_config.py @@ -3208,7 +3208,7 @@ def upgrade_datastore_128(self) -> None: - bat_tesvolt -> bat with version:2 (tesvolt) """ upgraded = [] - + def upgrade_component(topic: str, payload) -> Optional[dict]: if re.search(r"^openWB/system/device/[0-9]+/component/[0-9]+/config$", topic) is not None: component = decode_payload(payload) @@ -3252,9 +3252,9 @@ def upgrade_component(topic: str, payload) -> Optional[dict]: upgraded.append(topic) return {topic: component} return None - + self._loop_all_received_topics(upgrade_component) - + if upgraded: pub_system_message( {}, From 62d7cf1b25ddd17e8cf9903a611d3b65d72edf7b Mon Sep 17 00:00:00 2001 From: SeaSpotter Date: Sat, 13 Jun 2026 11:12:18 +0200 Subject: [PATCH 4/4] flake8 --- packages/helpermodules/update_config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/helpermodules/update_config.py b/packages/helpermodules/update_config.py index 57ec23a34d..b2169ac36a 100644 --- a/packages/helpermodules/update_config.py +++ b/packages/helpermodules/update_config.py @@ -3262,5 +3262,5 @@ def upgrade_component(topic: str, payload) -> Optional[dict]: "Deine bestehenden Einstellungen wurden automatisch übernommen.", MessageType.INFO ) - + self._append_datastore_version(128)