From 08ded62f4a56d196ba3406a756a06ece5a43f5b1 Mon Sep 17 00:00:00 2001 From: Andrey Date: Fri, 9 Jan 2026 22:42:43 +0300 Subject: [PATCH] defaultSubitem core optimization AC haier - sendinng command only after initial poll --- lighthub/item.cpp | 18 ++++++++++++++---- lighthub/modules/out_ac.cpp | 9 +++++++-- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/lighthub/item.cpp b/lighthub/item.cpp index 8689135..f5afa52 100644 --- a/lighthub/item.cpp +++ b/lighthub/item.cpp @@ -307,7 +307,7 @@ Item::~Item() Item::Item(char *name, aJsonObject *_items) //Constructor { - char * pDefaultSubItem = defaultSubItem; + // char * pDefaultSubItem = defaultSubItem; rootItems=_items; driver = NULL; defaultSubItem[0] =0; @@ -323,10 +323,20 @@ Item::Item(char *name, aJsonObject *_items) //Constructor buf[i]=0; itemArr = aJson.getObjectItem(rootItems, buf); sub++; + + for(i=0;(sub[i] && (sub[i]!='/') && (ichild) == num) { - debugSerial<<"CAN: Find item: "<< itemArr->name << " id:" << num << "sub:" << subItem; + debugSerial<<"CAN: Find item: "<< itemArr->name << " id:" << num << " sub:" << subItem; Parse(); if (subItem & SUBITEM_IS_COMMAND) { @@ -1600,7 +1610,7 @@ if ((!driver || driver->isAllowed(cmd)) { // UPDATE internal variables if (status2Send) cmd.saveItem(this,status2Send); - else debugSerial<<"NOT SAVED"<Ctrl(cmd, subItem, toExecute,authorized); if (driver->getChanType() == CH_THERMO) status2Send |= FLAG_SEND_IMMEDIATE; diff --git a/lighthub/modules/out_ac.cpp b/lighthub/modules/out_ac.cpp index da792bb..439ebfa 100644 --- a/lighthub/modules/out_ac.cpp +++ b/lighthub/modules/out_ac.cpp @@ -276,6 +276,7 @@ byte getCRC(byte req[], size_t size){ void out_AC::SendData(byte req[], size_t size){ if (!store || !item) return; +if (!store->data[0]) return; //Sending disabled until first poll if (Status() == AC_SENDING) { while (store->timestamp && !isTimeOver(store->timestamp,millis(),150)) yield(); @@ -326,8 +327,8 @@ if (!store) return 0;} memset(store->data,0,sizeof(acPersistent::data)); -store->data[0]=255; -store->data[1]=255; +//store->data[0]=255; +//store->data[1]=255; store->data[2]=0x22; store->mode=0; store->power=0; @@ -428,6 +429,10 @@ case AC_AWAITINGCMD: //Flusing port for 5 sec, poll status SendData(qstn, sizeof(qstn)/sizeof(byte)); //Опрос кондиционера store->timestamp=millisNZ(); setStatus(AC_IDLE); + + //Enable sending + store->data[0]=255; + store->data[1]=255; }