separation of production and development

environments
Adding new migrations for renaming and adding fields
to the database schema
persistent uuid for simclient
This commit is contained in:
2025-07-16 08:50:42 +00:00
parent 84a92ab9c2
commit 1a6faaa104
7 changed files with 116 additions and 12 deletions

View File

@@ -1 +1,2 @@
paho-mqtt
dotenv

View File

@@ -142,9 +142,22 @@ def send_discovery(client, client_id, hardware_token, ip_addr):
logging.info(f"Discovery-Nachricht gesendet: {discovery_msg}")
def get_persistent_uuid(uuid_path="/data/client_uuid.txt"):
# Prüfe, ob die Datei existiert
if os.path.exists(uuid_path):
with open(uuid_path, "r") as f:
return f.read().strip()
# Generiere neue UUID und speichere sie
new_uuid = str(uuid.uuid4())
os.makedirs(os.path.dirname(uuid_path), exist_ok=True)
with open(uuid_path, "w") as f:
f.write(new_uuid)
return new_uuid
def main():
global discovered
client_id = str(uuid.uuid4())
client_id = get_persistent_uuid()
hardware_token = get_hardware_token()
ip_addr = get_ip()
client = mqtt.Client(protocol=mqtt.MQTTv311, callback_api_version=2)