From 00969f88a46d92999f7b2faa787fb37bbadbe549 Mon Sep 17 00:00:00 2001 From: "anklimov@gmail.com" Date: Sun, 5 Apr 2026 00:53:44 +0300 Subject: [PATCH] MultiAC pre-release --- build-flags/build_flags_esp8266-wifi | 3 +- lighthub/modules/out_multivent.cpp | 52 +++++++++++++++++++--------- platformio.ini | 2 ++ 3 files changed, 40 insertions(+), 17 deletions(-) diff --git a/build-flags/build_flags_esp8266-wifi b/build-flags/build_flags_esp8266-wifi index df30a3e..1711836 100644 --- a/build-flags/build_flags_esp8266-wifi +++ b/build-flags/build_flags_esp8266-wifi @@ -17,7 +17,8 @@ -DRESTART_LAN_ON_MQTT_ERRORS -D CORS=\"*\" --D REDIRECTION_URL=\"http://lazyhome.ru/pwa\" +#-D REDIRECTION_URL=\"http://lazyhome.ru/pwa\" +-D REDIRECTION_URL=lazyhome.ru/pwa -DOTA_PORT=80 #oct22 - violation in Publish/OnMQTTConnect while publish homie info diff --git a/lighthub/modules/out_multivent.cpp b/lighthub/modules/out_multivent.cpp index a960691..28366b4 100644 --- a/lighthub/modules/out_multivent.cpp +++ b/lighthub/modules/out_multivent.cpp @@ -189,7 +189,8 @@ int out_Multivent::Poll(short cause) int set = getIntFromJson(i,"set"); int val = getIntFromJson(i,"val"); - int execCmd = 0; + int execCmd = 0; + bool weakMode=false; // kind of modes when we activating PID only if AC in active mode switch (cmd) { case CMD_HEATCOOL: @@ -200,10 +201,12 @@ int out_Multivent::Poll(short cause) break; case CMD_FAN: ventRequested = true; + weakMode = true; execCmd = cmd; break; case CMD_AUTO: autoRequested = true; + weakMode = true; execCmd = cmd; break; case CMD_COOL: @@ -216,30 +219,32 @@ int out_Multivent::Poll(short cause) bool passiveMode = getIntFromJson(i,"@pasv",0); aJsonObject * pidObj = aJson.getObjectItem(i, "pid"); - if (pidObj && pidObj->valueint) + aJsonObject * poObj = aJson.getObjectItem(i,"po"); + + if (pidObj && pidObj->valueint && poObj && poObj->type == aJson_Float) { PID * p = (PID *) pidObj->valueint; if ((execCmd == CMD_HEAT || execCmd == CMD_COOL) && p->GetMode() == AUTOMATIC) pidActive = true; - - switch (actualMode) + switch (actualMode) { //if air hot or cold - uses temp PID and block control by /fan case CMD_HEAT: - p->SetMode(AUTOMATIC); + if (weakMode || passiveMode) p->SetMode(AUTOMATIC); p->SetControllerDirection(DIRECT); break; case CMD_COOL: - p->SetMode(AUTOMATIC); + if (weakMode || passiveMode) p->SetMode(AUTOMATIC); p->SetControllerDirection(REVERSE); break; default: - if (passiveMode || execCmd == CMD_AUTO || execCmd ==CMD_OFF) p->SetMode(MANUAL); - } - + if ((passiveMode || weakMode || execCmd ==CMD_OFF) && p->GetMode() == AUTOMATIC) + { + p->SetMode(MANUAL); + debugSerial<name<name,true,true); + } + } if (p->Compute()) { - - aJsonObject * poObj = aJson.getObjectItem(i,"po"); - if (poObj && poObj->type == aJson_Float) { debugSerial<itemArr->name<<"/"<name @@ -288,9 +293,16 @@ int out_Multivent::Poll(short cause) ((PID *) pidObj->valueint)->SetMode(MANUAL); } } - } - } + } + else //PID not computed - maybe not in time, but we can use PID output as indicator of balance and boost if needed + { + if (p->GetMode() == AUTOMATIC) + { + if (execCmd == CMD_HEAT) balance+=poObj->valuefloat; + else if (execCmd == CMD_COOL) balance-=poObj->valuefloat; + } + } } } @@ -578,9 +590,15 @@ while (i) else if (cmd.getCmd() == CMD_AUTO) { setPassiveMode(i,true); //Setup flag + passiveMode = true; cmd.Cmd(CMD_OFF); cmd.setSuffix(S_CMD); } + else if (cmd.getCmd() == CMD_OFF) + { + setPassiveMode(i,false); + passiveMode = false; + } if (!cmd.isCommand()) break; // if have command in FAN suffix - continue processing debugSerial<<"VENT: cmd in FAN suffix, process as command. cmd="<valueint<valueint = CMD_OFF; enablePid(pidObj,false); break; diff --git a/platformio.ini b/platformio.ini index 4d3a41f..96130c3 100644 --- a/platformio.ini +++ b/platformio.ini @@ -637,6 +637,8 @@ extra_scripts = extra_script.py ;;;; WEMOS D1 ;;;;; board = d1_mini +board_build.ldscript = eagle.flash.4m1m.ld + ; change microcontroller board_build.mcu = esp8266 ; change MCU frequency