From 241d0edc9482c8e06ad0734a03ef5072d6fcd10c Mon Sep 17 00:00:00 2001 From: Maciej Bieniek Date: Tue, 12 Nov 2024 21:31:44 +0100 Subject: [PATCH] Fix via_device value for DeviceInfo (#519) * Fix via_device * Bump version --- python_scripts/shellies_discovery_gen2.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/python_scripts/shellies_discovery_gen2.py b/python_scripts/shellies_discovery_gen2.py index 2d31817..caf93ea 100644 --- a/python_scripts/shellies_discovery_gen2.py +++ b/python_scripts/shellies_discovery_gen2.py @@ -1,6 +1,6 @@ """This script adds MQTT discovery support for Shellies Gen2 devices.""" -VERSION = "3.5.1" +VERSION = "3.5.2" ATTR_BATTERY_POWERED = "battery_powered" ATTR_BINARY_SENSORS = "binary_sensors" @@ -4225,6 +4225,8 @@ def remove_old_script_versions(device_topic, script_topic): config_data = {} + via_device = format_mac(device_id.rsplit("-", 1)[-1]) + for device, config in bthome_devices.items(): btdevice_id = device.split(":")[-1] if f"blutrv:{btdevice_id}" in blutrv_devices: @@ -4247,7 +4249,6 @@ def remove_old_script_versions(device_topic, script_topic): logger.debug("Found BTHome devices: %s", bthome_devices) # noqa: F821 mac = config["addr"].lower() - via_device = format_mac(device_id.rsplit("-", 1)[-1]) device_name = config["name"] or SUPPORTED_MODELS[model][ATTR_NAME] device_id += f"-{mac.replace(":", "")}" device_info = { @@ -4290,7 +4291,6 @@ def remove_old_script_versions(device_topic, script_topic): for thermostat, config in blutrv_devices.items(): model = MODEL_BLU_TRV mac = config["addr"].lower() - via_device = format_mac(device_id.rsplit("-", 1)[-1]) device_name = config["name"] or SUPPORTED_MODELS[model][ATTR_NAME] device_id += f"-{mac.replace(":", "")}" device_info = {