Skip to content

Commit ddbd3d1

Browse files
Dennis Braunclaude
andcommitted
Add configurable MQTT discovery prefix (fixes #12)
Users with a custom HA discovery prefix (e.g. 'discover') can now configure it via UI or MQTT_DISCOVERY_PREFIX env var. Default remains 'homeassistant' for backward compatibility. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent cc7cdc5 commit ddbd3d1

File tree

8 files changed

+21
-0
lines changed

8 files changed

+21
-0
lines changed

app/config.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
"mqtt_user": "",
2727
"mqtt_password": "",
2828
"mqtt_topic_prefix": "docsight",
29+
"mqtt_discovery_prefix": "homeassistant",
2930
"poll_interval": 900,
3031
"web_port": 8765,
3132
"history_days": 0,
@@ -50,6 +51,7 @@
5051
"mqtt_user": "MQTT_USER",
5152
"mqtt_password": "MQTT_PASSWORD",
5253
"mqtt_topic_prefix": "MQTT_TOPIC_PREFIX",
54+
"mqtt_discovery_prefix": "MQTT_DISCOVERY_PREFIX",
5355
"poll_interval": "POLL_INTERVAL",
5456
"web_port": "WEB_PORT",
5557
"history_days": "HISTORY_DAYS",

app/i18n/de.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,8 @@
114114
"username_opt": "Benutzername (optional)",
115115
"password_opt": "Passwort (optional)",
116116
"topic_prefix": "Topic-Prefix",
117+
"discovery_prefix": "Discovery-Prefix",
118+
"discovery_prefix_hint": "Standard: homeassistant. Nur aendern, wenn du es in HA angepasst hast.",
117119
"complete_setup": "Einrichtung abschliessen",
118120
"testing": "Teste...",
119121
"connected": "Verbunden",

app/i18n/en.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,8 @@
114114
"username_opt": "Username (optional)",
115115
"password_opt": "Password (optional)",
116116
"topic_prefix": "Topic Prefix",
117+
"discovery_prefix": "Discovery Prefix",
118+
"discovery_prefix_hint": "Default: homeassistant. Only change if you customized it in HA.",
117119
"complete_setup": "Complete Setup",
118120
"testing": "Testing...",
119121
"connected": "Connected",

app/i18n/es.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,8 @@
114114
"username_opt": "Usuario (opcional)",
115115
"password_opt": "Contraseña (opcional)",
116116
"topic_prefix": "Prefijo de topic",
117+
"discovery_prefix": "Prefijo de descubrimiento",
118+
"discovery_prefix_hint": "Predeterminado: homeassistant. Solo cambia si lo personalizaste en HA.",
117119
"complete_setup": "Completar configuración",
118120
"testing": "Probando...",
119121
"connected": "Conectado",

app/i18n/fr.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,8 @@
114114
"username_opt": "Nom d'utilisateur (optionnel)",
115115
"password_opt": "Mot de passe (optionnel)",
116116
"topic_prefix": "Préfixe de topic",
117+
"discovery_prefix": "Préfixe de découverte",
118+
"discovery_prefix_hint": "Défaut : homeassistant. Ne changez que si vous l'avez personnalisé dans HA.",
117119
"complete_setup": "Terminer la configuration",
118120
"testing": "Test en cours...",
119121
"connected": "Connecté",

app/main.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ def polling_loop(config_mgr, storage, stop_event):
4343
user=mqtt_user,
4444
password=mqtt_password,
4545
topic_prefix=config["mqtt_topic_prefix"],
46+
ha_prefix=config["mqtt_discovery_prefix"],
4647
)
4748
try:
4849
mqtt_pub.connect()

app/templates/settings.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,11 @@ <h2>{{ t.general }}</h2>
290290
<label for="mqtt_topic_prefix">{{ t.topic_prefix }}</label>
291291
<input type="text" id="mqtt_topic_prefix" name="mqtt_topic_prefix" value="{{ config.mqtt_topic_prefix }}">
292292
</div>
293+
<div class="form-row full">
294+
<label for="mqtt_discovery_prefix">{{ t.discovery_prefix }}</label>
295+
<input type="text" id="mqtt_discovery_prefix" name="mqtt_discovery_prefix" value="{{ config.mqtt_discovery_prefix }}" placeholder="homeassistant">
296+
<span class="hint">{{ t.discovery_prefix_hint }}</span>
297+
</div>
293298
</div>
294299
<div class="btn-row">
295300
<button type="button" class="btn btn-secondary" onclick="testMqtt()">{{ t.test_connection }}</button>

app/templates/setup.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,11 @@ <h2>{{ t.mqtt_broker }}</h2>
287287
<label for="mqtt_topic_prefix">{{ t.topic_prefix }}</label>
288288
<input type="text" id="mqtt_topic_prefix" name="mqtt_topic_prefix" value="{{ config.mqtt_topic_prefix }}" placeholder="docsight">
289289
</div>
290+
<div class="form-row full">
291+
<label for="mqtt_discovery_prefix">{{ t.discovery_prefix }}</label>
292+
<input type="text" id="mqtt_discovery_prefix" name="mqtt_discovery_prefix" value="{{ config.mqtt_discovery_prefix }}" placeholder="homeassistant">
293+
<span class="hint">{{ t.discovery_prefix_hint }}</span>
294+
</div>
290295
</div>
291296
<div class="btn-row">
292297
<button type="button" class="btn btn-secondary" onclick="testMqtt()">{{ t.test_connection }}</button>

0 commit comments

Comments
 (0)