Discovery didn't set online status

This commit is contained in:
2026-04-15 00:44:22 +02:00
parent a9fc7cd0ed
commit 036fa045f8
2 changed files with 8 additions and 1 deletions

View File

@@ -10,7 +10,7 @@ static const uint8_t GAUGE_COUNT = 2;
static const uint8_t LED_DATA_PIN = 22;
// For now: commands come over USB serial
#define CMD_PORT Serial
#define CMD_PORT Serial1
#define DEBUG_PORT Serial
struct GaugePins {

View File

@@ -642,6 +642,7 @@ def check_mqtt():
info("MQTT reconnected!")
publish_discovery(client_ref)
_subscribe_all(client_ref)
publish_online(client_ref)
publish_state(client_ref)
publish_backlight_states(client_ref)
return True
@@ -789,6 +790,11 @@ def publish_discovery(client):
utime.sleep_ms(10)
def publish_online(client):
for i in range(num_gauges):
client.publish(gauge_topics[i]["status"], b"online", retain=True)
def publish_state(client):
for i in range(num_gauges):
gt = gauge_topics[i]
@@ -825,6 +831,7 @@ def main():
info("Home command sent")
info("Publishing state...")
publish_online(client_ref)
publish_state(client_ref)
utime.sleep_ms(50)
for _ in range(5):