From bfbb6519f8d207ec558a529b707801a3b69a3171 Mon Sep 17 00:00:00 2001 From: Denis Denisov Date: Sun, 7 Dec 2025 15:09:14 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9E=D1=82=D1=81=D0=B5=D1=87=D0=BA=D0=B0=20?= =?UTF-8?q?=D0=BF=D0=BE=20=D1=82=D0=B5=D0=BC=D0=BF=D0=B5=D1=80=D0=B0=D1=82?= =?UTF-8?q?=D1=83=D1=80=D0=B5=20=D0=B2=D1=8B=D1=85=D0=BE=D0=B4=D0=B0=20?= =?UTF-8?q?=D0=B1=D0=BE=D0=B9=D0=BB=D0=B5=D1=80=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- heat_control.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/heat_control.py b/heat_control.py index 2974ba9..5c6b9ca 100644 --- a/heat_control.py +++ b/heat_control.py @@ -21,8 +21,11 @@ CONFIG_FILE = "config.json" # will turn on boiler after this amount of opened contour time # (this is to make sure valve has time for opening) BOILER_TURN_ON_AFTER = 90 +# will turn off boiler if it's exhaust temperature is too high +BOILER_EXHAUST_LIMIT = 50 contours = [] +boiler_exhaust_t = 0 config: Dict[str, Any] = {} # MQTT client @@ -72,17 +75,23 @@ def on_connect(client, userdata, flags, rc): for k in contours: client.subscribe(k.sensor_topic) logger.info(f"Subscribed to: {k.sensor_topic}") + # and boiler exhaust topic + client.subscribe(config.get('boiler_exhaust_t')) else: logger.error(f"Connection failed with code: {rc}") def on_message(client, userdata, msg): """MQTT message callback - store temperature values""" + global contours, boiler_exhaust_t try: for k in contours: if (k.sensor_topic == msg.topic): temperature = float(msg.payload.decode('utf-8')) k.update(temperature) logger.debug(f"Updated {k.sensor_topic}: {temperature}°C") + if msg.topic == config.get('boiler_exhaust_t'): + boiler_exhaust_t = float(msg.payload.decode('utf-8')) + logger.debug(f"Updated boiler exhaust: {boiler_exhaust_t}°C") except ValueError: logger.error(f"Invalid temperature value: {msg.payload}") except Exception as e: @@ -94,6 +103,17 @@ any_opened = False def check_temperatures(): """Check temperatures against target and control GPIO""" global any_opened_start, any_opened + # check boiler exhaust, turn off if too big + if (boiler_exhaust_t > BOILER_EXHAUST_LIMIT): + logger.error("Boiler exhaust overheat") + # will open all contours (to force coolant circulation) + # and turn off the boiler of course + for c in contours: + # valves are normally-opened, so 0 means "open" + mqtt_client.publish(c.out_topic, "0", retain=True) + mqtt_client.publish(boiler_control, "0", retain=True) + return + # sum_t = 0 count_t = 0 for c in contours: