diff --git a/data/config/mosquitto/openwb_local.conf b/data/config/mosquitto/openwb_local.conf index f540b3dcf1..e9acb2edc3 100644 --- a/data/config/mosquitto/openwb_local.conf +++ b/data/config/mosquitto/openwb_local.conf @@ -1,4 +1,4 @@ -# openwb-version:19 +# openwb-version:20 listener 1886 localhost allow_anonymous true @@ -33,8 +33,6 @@ topic openWB/internal_chargepoint/# out 2 topic openWB/io/# out 2 topic openWB/internal_io/# out 2 -topic openWB/mqtt/# both 2 - topic openWB/pv/config/configured out 2 topic openWB/pv/get/# out 2 topic openWB/pv/+/config/# out 2 diff --git a/packages/helpermodules/pub.py b/packages/helpermodules/pub.py index 1f5f15c2b2..fb6c0017b5 100644 --- a/packages/helpermodules/pub.py +++ b/packages/helpermodules/pub.py @@ -45,6 +45,8 @@ def pub_single(topic, payload, hostname="localhost", port=1883, no_json=False, r no_json: bool Kompatibilität mit ISSS, die ramdisk verwenden. """ + if payload == "": + no_json = True if no_json: publish.single(topic, payload, hostname=hostname, port=port, retain=retain) else: diff --git a/packages/helpermodules/update_config.py b/packages/helpermodules/update_config.py index 40daa6a85b..7204994976 100644 --- a/packages/helpermodules/update_config.py +++ b/packages/helpermodules/update_config.py @@ -28,7 +28,7 @@ from helpermodules.measurement_logging.process_log import get_default_charge_log_columns, get_totals from helpermodules.measurement_logging.write_log import get_names from helpermodules.messaging import MessageType, pub_system_message -from helpermodules.pub import Pub +from helpermodules.pub import Pub, pub_single from helpermodules.utils.json_file_handler import write_and_check from helpermodules.utils.run_command import run_command from helpermodules.utils.topic_parser import decode_payload, get_index, get_second_index @@ -56,7 +56,7 @@ class UpdateConfig: - DATASTORE_VERSION = 89 + DATASTORE_VERSION = 90 valid_topic = [ "^openWB/bat/config/bat_control_permitted$", @@ -2348,3 +2348,21 @@ def upgrade_datastore_88(self) -> None: pub_system_message({}, "Es gibt ein neues Theme: das Koala-Theme! Smarthpone-optimiert und mit " "Energiefluss-Diagramm & Karten-Ansicht der Ladepunkte", MessageType.INFO) self.__update_topic("openWB/system/datastore_version", 89) + + def upgrade_datastore_89(self) -> None: + def on_connect(client, userdata, flags, rc): + client.subscribe("openWB/mqtt/#") + + def on_message(client, userdata, message): + topics_to_delete.append(message.topic) + + topics_to_delete = [] + BrokerClient("deleteMqttDeviceExternalBroker", + on_connect, + on_message, + host="localhost", + port=1883).start_finite_loop() + for topic in topics_to_delete: + log.debug(f"Lösche MQTT-Device-Topic {topic} auf dem externen Broker") + pub_single(topic, "", port=1884) + self.__update_topic("openWB/system/datastore_version", 90)