fix unknown value on startup
This commit is contained in:
parent
dcd66bf9fc
commit
958d33f366
9
main.py
9
main.py
@ -282,14 +282,21 @@ class GadgetbridgeMQTTPublisher:
|
||||
) as client:
|
||||
self.mqtt_client = client
|
||||
await self.setup_home_assistant_entities()
|
||||
while True:
|
||||
# Publish immediately on startup
|
||||
steps_data = self.get_steps_data()
|
||||
if steps_data:
|
||||
await self.publish_steps_data(steps_data)
|
||||
self.logger.info(
|
||||
f"Sleeping for {self.publish_interval} seconds before next publish..."
|
||||
)
|
||||
while True:
|
||||
await asyncio.sleep(self.publish_interval)
|
||||
steps_data = self.get_steps_data()
|
||||
if steps_data:
|
||||
await self.publish_steps_data(steps_data)
|
||||
self.logger.info(
|
||||
f"Sleeping for {self.publish_interval} seconds before next publish..."
|
||||
)
|
||||
except Exception as e:
|
||||
self.logger.error(f"Failed to connect to MQTT broker: {e}")
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user