Discovery problems

This commit is contained in:
2026-04-13 01:27:15 +02:00
parent fe0432341e
commit 80bacb4b39

View File

@@ -667,9 +667,10 @@ def publish_discovery(client):
)
info(f"Discovery: gauge {i} ({g['name']})")
# Process MQTT messages between publishes
# Process MQTT messages between gauges
for _ in range(5):
client.check_msg()
utime.sleep_ms(30)
utime.sleep_ms(10)
client.publish(
gt["led_red_disc"],
@@ -771,6 +772,11 @@ def publish_discovery(client):
)
info(f"Discovery: gauge {i} status green")
# Process between gauges to avoid MQTT blocking
for _ in range(5):
client.check_msg()
utime.sleep_ms(10)
def publish_state(client):
for i, g in enumerate(gauge_objects):
@@ -794,14 +800,17 @@ def main():
connect_wifi(WIFI_SSID, WIFI_PASSWORD)
# Check if we need to publish discovery
discovery_published = False
try:
with open(".discovery_ok", "r") as f:
discovery_published = f.read()
info("Discovery flag file exists, skipping discovery")
content = f.read()
if content.strip() == "ok":
discovery_published = True
info("Discovery flag exists - skipping discovery")
except:
info("No discovery flag file - publishing discovery")
discovery_published = False
info("No discovery flag - will publish discovery")
info(f"Discovery: {discovery_published}")
# Connect MQTT first (needed for discovery)
connect_mqtt()