From ecef18cac3d48a6ad17038f4f47f4072ca3fa602 Mon Sep 17 00:00:00 2001 From: fredlcore Date: Mon, 11 Dec 2023 09:48:46 +0800 Subject: [PATCH] Calculate average room temperature based on MAX! thermostats and send it to the heater --- .../BSB_LAN_custom.h | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 BSB_LAN/custom_functions/Send_room_temperature_based_on_MAX_thermostats/BSB_LAN_custom.h diff --git a/BSB_LAN/custom_functions/Send_room_temperature_based_on_MAX_thermostats/BSB_LAN_custom.h b/BSB_LAN/custom_functions/Send_room_temperature_based_on_MAX_thermostats/BSB_LAN_custom.h new file mode 100644 index 00000000..4b0d79b4 --- /dev/null +++ b/BSB_LAN/custom_functions/Send_room_temperature_based_on_MAX_thermostats/BSB_LAN_custom.h @@ -0,0 +1,38 @@ +/* + * Calculate the average of all MAX! wall and heating thermostats + * and send this as the current room temperature to the heating system. +*/ + +if (custom_timer > custom_timer_compare+60000) { // every 60 seconds + custom_timer_compare = millis(); + + max_cul.println(F("Zr")); // periodically (re-)activate "Moritz" mode on Cube to receive MAX messages + int max_avg_count = 0; + float max_avg = 0; + for (int x=0;x<20;x++) { + if (max_cur_temp[x] > 0) { + max_avg += (float)max_cur_temp[x] / 10; + max_avg_count++; +/* + // Debug output + Serial.print(max_devices[x], HEX); + Serial.print(F(": ")); + Serial.print((float)max_cur_temp[x] / 10); // Current temperature + Serial.print(F(" / ")); + Serial.print((float)max_dst_temp[x] / 2); // Desired temperature + Serial.print(F(" / ")); + Serial.println(max_valve[x]); // Valve opening in percent +*/ + } + } + if (max_avg_count > 0) { + Serial.print(F("Avgerage temperature based on all MAX! thermostats: ")); + Serial.println(max_avg / max_avg_count); + + char set_temp[6]; + dtostrf((max_avg/max_avg_count), 1, 1, set_temp); // Convert temperature value to char as required by set() function + Serial.print(F("Setting room temperature to ")); + Serial.println(set_temp); + set(10000, set_temp, 0); + } +}