Skip to content

Commit 5327ec9

Browse files
committed
fix: format MQTT handler and strategy topics with zero-padded indices for ASCII sorting properly
1 parent bd46757 commit 5327ec9

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

heatpump/thermia_heatpump.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1191,7 +1191,7 @@ def publish_strategies_to_mqtt(self):
11911191
for index, (start_time, handler) in enumerate(
11921192
self.high_price_handlers.items()
11931193
):
1194-
mqtt_handler_topic = handlers_prefix + str(index)
1194+
mqtt_handler_topic = handlers_prefix + f"{index:02d}"
11951195
self.mqtt_client.generic_publish(
11961196
mqtt_handler_topic,
11971197
start_time.strftime("%Y-%m-%d_%H:%M")
@@ -1224,7 +1224,7 @@ def publish_strategies_to_mqtt(self):
12241224
for index, (start_time, strategy) in enumerate(
12251225
self.high_price_strategies.items()
12261226
):
1227-
high_price_strategy_topic = strategies_prefix + str(index)
1227+
high_price_strategy_topic = strategies_prefix + f"{index:02d}"
12281228
self.mqtt_client.generic_publish(
12291229
high_price_strategy_topic,
12301230
start_time.strftime("%Y-%m-%d %H:%M") + ":" + strategy.mode,

0 commit comments

Comments
 (0)