Bladeren bron

fix(mqtt): allow custom client ID override, stop writing literal default (#125)

Rebased onto main's random-suffix client ID generation:
- set_mqtt_config no longer stores the literal 'dune_weaver' when the
  field is empty (which shadowed auto-generation until restart)
- Settings UI gains an optional Client ID field; empty = auto-generated
  unique ID, so multiple tables no longer kick each other off the broker

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
m8tec 4 dagen geleden
bovenliggende
commit
099ed30b9c

+ 16 - 0
frontend/src/pages/SettingsPage.tsx

@@ -1749,6 +1749,22 @@ export function SettingsPage() {
                       }
                     />
                   </div>
+                  <div className="space-y-3 md:col-span-2">
+                    <Label htmlFor="mqttClientId">Client ID (optional)</Label>
+                    <Input
+                      id="mqttClientId"
+                      value={mqttConfig.client_id || ''}
+                      onChange={(e) =>
+                        setMqttConfig({ ...mqttConfig, client_id: e.target.value })
+                      }
+                      placeholder="Auto (unique ID based on Device ID)"
+                    />
+                    <p className="text-xs text-muted-foreground">
+                      {mqttConfig.client_id?.trim()
+                        ? 'Using custom Client ID override. Must be unique per table on the broker.'
+                        : 'Leave empty to auto-generate a unique broker client ID from the Device ID.'}
+                    </p>
+                  </div>
                 </div>
 
                 <Alert className="flex items-start">

+ 1 - 1
main.py

@@ -3291,7 +3291,7 @@ async def set_mqtt_config(request: dict):
         state.mqtt_port = int(request.get("port") or 1883)
         state.mqtt_username = (request.get("username") or "").strip()
         state.mqtt_password = (request.get("password") or "").strip()
-        state.mqtt_client_id = (request.get("client_id") or "dune_weaver").strip()
+        state.mqtt_client_id = (request.get("client_id") or "").strip() or None
         state.mqtt_discovery_prefix = (request.get("discovery_prefix") or "homeassistant").strip()
         state.mqtt_device_id = (request.get("device_id") or "dune_weaver").strip()
         state.mqtt_device_name = (request.get("device_name") or "Dune Weaver").strip()

File diff suppressed because it is too large
+ 0 - 0
static/dist/assets/index-BdTg2vct.css


File diff suppressed because it is too large
+ 0 - 0
static/dist/assets/index-D3rZVjEB.js


+ 2 - 2
static/dist/index.html

@@ -58,8 +58,8 @@
           .catch(function() {});
       })();
     </script>
-    <script type="module" crossorigin src="/assets/index-BdHxEIen.js"></script>
-    <link rel="stylesheet" crossorigin href="/assets/index-CHzltdTQ.css">
+    <script type="module" crossorigin src="/assets/index-D3rZVjEB.js"></script>
+    <link rel="stylesheet" crossorigin href="/assets/index-BdTg2vct.css">
   <script id="vite-plugin-pwa:register-sw" src="/registerSW.js"></script></head>
   <body>
     <div id="root"></div>

File diff suppressed because it is too large
+ 0 - 0
static/dist/sw.js


Some files were not shown because too many files changed in this diff