From 3beb465247d06bed789025b9857105f3f2496e5e Mon Sep 17 00:00:00 2001
From: Timofey Titovets <nefelim4ag@gmail.com>
Date: Mon, 23 Dec 2024 22:50:24 +0100
Subject: [PATCH] temperature_combined: delay initialization

Signed-off-by: Timofey Titovets <nefelim4ag@gmail.com>
---
 klippy/extras/temperature_combined.py | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/klippy/extras/temperature_combined.py b/klippy/extras/temperature_combined.py
index 954166196..f5aafd1e6 100644
--- a/klippy/extras/temperature_combined.py
+++ b/klippy/extras/temperature_combined.py
@@ -52,8 +52,10 @@ class PrinterSensorCombined:
 
     def _handle_ready(self):
         # Start temperature update timer
+        # There is a race condition with sensors where they can be not ready,
+        # and return 0 or None - initialize a little bit later.
         self.reactor.update_timer(self.temperature_update_timer,
-                                  self.reactor.NOW)
+                                  self.reactor.monotonic() + 1.)
 
     def setup_minmax(self, min_temp, max_temp):
         self.min_temp = min_temp