Discovery didn't set online status
This commit is contained in:
@@ -10,7 +10,7 @@ static const uint8_t GAUGE_COUNT = 2;
|
|||||||
static const uint8_t LED_DATA_PIN = 22;
|
static const uint8_t LED_DATA_PIN = 22;
|
||||||
|
|
||||||
// For now: commands come over USB serial
|
// For now: commands come over USB serial
|
||||||
#define CMD_PORT Serial
|
#define CMD_PORT Serial1
|
||||||
#define DEBUG_PORT Serial
|
#define DEBUG_PORT Serial
|
||||||
|
|
||||||
struct GaugePins {
|
struct GaugePins {
|
||||||
|
|||||||
7
gauge.py
7
gauge.py
@@ -642,6 +642,7 @@ def check_mqtt():
|
|||||||
info("MQTT reconnected!")
|
info("MQTT reconnected!")
|
||||||
publish_discovery(client_ref)
|
publish_discovery(client_ref)
|
||||||
_subscribe_all(client_ref)
|
_subscribe_all(client_ref)
|
||||||
|
publish_online(client_ref)
|
||||||
publish_state(client_ref)
|
publish_state(client_ref)
|
||||||
publish_backlight_states(client_ref)
|
publish_backlight_states(client_ref)
|
||||||
return True
|
return True
|
||||||
@@ -789,6 +790,11 @@ def publish_discovery(client):
|
|||||||
utime.sleep_ms(10)
|
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):
|
def publish_state(client):
|
||||||
for i in range(num_gauges):
|
for i in range(num_gauges):
|
||||||
gt = gauge_topics[i]
|
gt = gauge_topics[i]
|
||||||
@@ -825,6 +831,7 @@ def main():
|
|||||||
info("Home command sent")
|
info("Home command sent")
|
||||||
|
|
||||||
info("Publishing state...")
|
info("Publishing state...")
|
||||||
|
publish_online(client_ref)
|
||||||
publish_state(client_ref)
|
publish_state(client_ref)
|
||||||
utime.sleep_ms(50)
|
utime.sleep_ms(50)
|
||||||
for _ in range(5):
|
for _ in range(5):
|
||||||
|
|||||||
Reference in New Issue
Block a user