Отсечка по температуре выхода бойлера
This commit is contained in:
@@ -21,8 +21,11 @@ CONFIG_FILE = "config.json"
|
|||||||
# will turn on boiler after this amount of opened contour time
|
# will turn on boiler after this amount of opened contour time
|
||||||
# (this is to make sure valve has time for opening)
|
# (this is to make sure valve has time for opening)
|
||||||
BOILER_TURN_ON_AFTER = 90
|
BOILER_TURN_ON_AFTER = 90
|
||||||
|
# will turn off boiler if it's exhaust temperature is too high
|
||||||
|
BOILER_EXHAUST_LIMIT = 50
|
||||||
|
|
||||||
contours = []
|
contours = []
|
||||||
|
boiler_exhaust_t = 0
|
||||||
config: Dict[str, Any] = {}
|
config: Dict[str, Any] = {}
|
||||||
|
|
||||||
# MQTT client
|
# MQTT client
|
||||||
@@ -72,17 +75,23 @@ def on_connect(client, userdata, flags, rc):
|
|||||||
for k in contours:
|
for k in contours:
|
||||||
client.subscribe(k.sensor_topic)
|
client.subscribe(k.sensor_topic)
|
||||||
logger.info(f"Subscribed to: {k.sensor_topic}")
|
logger.info(f"Subscribed to: {k.sensor_topic}")
|
||||||
|
# and boiler exhaust topic
|
||||||
|
client.subscribe(config.get('boiler_exhaust_t'))
|
||||||
else:
|
else:
|
||||||
logger.error(f"Connection failed with code: {rc}")
|
logger.error(f"Connection failed with code: {rc}")
|
||||||
|
|
||||||
def on_message(client, userdata, msg):
|
def on_message(client, userdata, msg):
|
||||||
"""MQTT message callback - store temperature values"""
|
"""MQTT message callback - store temperature values"""
|
||||||
|
global contours, boiler_exhaust_t
|
||||||
try:
|
try:
|
||||||
for k in contours:
|
for k in contours:
|
||||||
if (k.sensor_topic == msg.topic):
|
if (k.sensor_topic == msg.topic):
|
||||||
temperature = float(msg.payload.decode('utf-8'))
|
temperature = float(msg.payload.decode('utf-8'))
|
||||||
k.update(temperature)
|
k.update(temperature)
|
||||||
logger.debug(f"Updated {k.sensor_topic}: {temperature}°C")
|
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:
|
except ValueError:
|
||||||
logger.error(f"Invalid temperature value: {msg.payload}")
|
logger.error(f"Invalid temperature value: {msg.payload}")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
@@ -94,6 +103,17 @@ any_opened = False
|
|||||||
def check_temperatures():
|
def check_temperatures():
|
||||||
"""Check temperatures against target and control GPIO"""
|
"""Check temperatures against target and control GPIO"""
|
||||||
global any_opened_start, any_opened
|
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
|
sum_t = 0
|
||||||
count_t = 0
|
count_t = 0
|
||||||
for c in contours:
|
for c in contours:
|
||||||
|
|||||||
Reference in New Issue
Block a user