diff --git a/.gitignore b/.gitignore index c94e4a3..6caeb0e 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ .vscode/launch.json .vscode/ipch /.vscode +/.vscode diff --git a/src/ise_display.cpp b/src/ise_display.cpp index 70508e3..097e3c7 100644 --- a/src/ise_display.cpp +++ b/src/ise_display.cpp @@ -535,6 +535,13 @@ void ISEDisplay::updatePMinside(u_int16_t pm25_inside) void ISEDisplay::setPMstate(bool is_pm_on, uint8_t pm_fan_speed) { + //check pm_lock if true do nothing + this->pm_lock_state = strcmp(pm_lock->getValue(), "on") == 0; + if (this->pm_lock_state == true) + { + ESP_LOGI("ISEDisplay", "PM lock is on, do nothing"); + return; + } ESP_LOGI("ISEDisplay", "Setting PM state: %d, fan speed: %d", is_pm_on, pm_fan_speed); char buffer[4]; itoa(pm_fan_speed, buffer, DEC); @@ -562,6 +569,13 @@ void ISEDisplay::setACstate(uint8_t ac_fan_speed, uint8_t ac_mode, uint8_t ac_te this->ac_fan_speed = ac_fan_speed; this->ac_mode = ac_mode; this->ac_temperature = ac_temperature; + //check ac_lock if true do nothing + this->ac_lock_state = strcmp(ac_lock->getValue(), "on") == 0; + if (this->ac_lock_state == true) + { + ESP_LOGI("ISEDisplay", "AC lock is on, do nothing"); + return; + } // check ac_temp is within bound of daikin if (this->ac_temperature < DAIKIN_MIN_TEMP) { @@ -1152,24 +1166,49 @@ bool ISEDisplay::calculateAllState() } void ISEDisplay::toggleSystem() { - toggleLightGroupState(); - // check for ac lock and pm lock, if lock is on do nothing - if (this->ac_lock_state == true) + // toggleLightGroupState(); + // // check for ac lock and pm lock, if lock is on do nothing + // if (this->ac_lock_state == true) + // { + // ESP_LOGI("ISEDisplay", "AC lock is on, do nothing"); + // } + // else + // { + // toggleAC(); + // } + // if (this->pm_lock_state == true) + // { + // ESP_LOGI("ISEDisplay", "PM lock is on, do nothing"); + // } + // else + // { + // togglePM(); + // } + + bool state = calculateAllState(); + if (state) { - ESP_LOGI("ISEDisplay", "AC lock is on, do nothing"); + //if AC mode is not zero, toggleAC() + if(ac_mode != 0) { + toggleAC(); + } + setLightGroupState(0); + setPMstate(false, pm_fan_speed); } else { - toggleAC(); - } - if (this->pm_lock_state == true) - { - ESP_LOGI("ISEDisplay", "PM lock is on, do nothing"); - } - else - { - togglePM(); + if(ac_mode == 0) { + toggleAC(); + } + setLightGroupState(3); + setPMstate(true, pm_fan_speed); } + + + + + + } void ISEDisplay::allToggleStandby() { diff --git a/src/main.cpp b/src/main.cpp index ce012c6..d2e6524 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -177,21 +177,33 @@ void setup() espmega.installCard(4, &analogCard); espmega.installCard(5, &ct1); ct1.bindFRAM(&espmega.fram, 6000); + ct1.loadEnergy(); + ct1.setEnergyAutoSave(true); espmega.iot->registerCard(5); espmega.installCard(6, &ct2); ct2.bindFRAM(&espmega.fram, 6100); + ct2.loadEnergy(); + ct2.setEnergyAutoSave(true); espmega.iot->registerCard(6); espmega.installCard(7, &ct3); ct3.bindFRAM(&espmega.fram, 6200); + ct3.loadEnergy(); + ct3.setEnergyAutoSave(true); espmega.iot->registerCard(7); espmega.installCard(8, &ct4); ct4.bindFRAM(&espmega.fram, 6300); + ct4.loadEnergy(); + ct4.setEnergyAutoSave(true); espmega.iot->registerCard(8); espmega.installCard(9, &ct5); ct5.bindFRAM(&espmega.fram, 6400); + ct5.loadEnergy(); + ct5.setEnergyAutoSave(true); espmega.iot->registerCard(9); espmega.installCard(10, &ct6); ct6.bindFRAM(&espmega.fram, 6500); + ct6.loadEnergy(); + ct6.setEnergyAutoSave(true); espmega.iot->registerCard(10); #endif