|
@ -593,29 +593,33 @@ void app::updateLed(void) { |
|
|
//-----------------------------------------------------------------------------
|
|
|
//-----------------------------------------------------------------------------
|
|
|
#if defined(ESP32) |
|
|
#if defined(ESP32) |
|
|
void app::zeroexport() { |
|
|
void app::zeroexport() { |
|
|
if (!mConfig->plugin.zexport.enabled && |
|
|
if (!mConfig->plugin.zexport.enabled) return; // check if plugin is enabled && indicate to send new value
|
|
|
!mConfig->plugin.zexport.rdytoSend) return; // check if plugin is enabled && indicate to send new value
|
|
|
|
|
|
|
|
|
|
|
|
Inverter<> *iv = mSys.getInverterByPos(mConfig->plugin.zexport.Iv); |
|
|
if (millis() - mConfig->plugin.zexport.lastTime < mConfig->plugin.zexport.count_avg * 1000UL) |
|
|
|
|
|
{ |
|
|
|
|
|
Inverter<> *iv = mSys.getInverterByPos(mConfig->plugin.zexport.Iv); |
|
|
|
|
|
|
|
|
DynamicJsonDocument doc(512); |
|
|
DynamicJsonDocument doc(512); |
|
|
JsonObject object = doc.to<JsonObject>(); |
|
|
JsonObject object = doc.to<JsonObject>(); |
|
|
|
|
|
|
|
|
double nValue = round(mzExport.getPowertoSetnewValue()); |
|
|
double nValue = round(mzExport.getPowertoSetnewValue()); |
|
|
double twoPerVal = nValue <= (iv->getMaxPower() / 100 * 2 ); |
|
|
double twoPerVal = nValue <= (iv->getMaxPower() / 100 * 2 ); |
|
|
if(mConfig->plugin.zexport.two_percent && (nValue <= twoPerVal)) { |
|
|
if(mConfig->plugin.zexport.two_percent && (nValue <= twoPerVal)) { |
|
|
object["val"] = twoPerVal; |
|
|
object["val"] = twoPerVal; |
|
|
} else { |
|
|
} else { |
|
|
object["val"] = nValue; |
|
|
object["val"] = nValue; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
object["id"] = mConfig->plugin.zexport.Iv; |
|
|
|
|
|
object["path"] = "ctrl"; |
|
|
|
|
|
object["cmd"] = "limit_nonpersistent_absolute"; |
|
|
|
|
|
|
|
|
object["id"] = mConfig->plugin.zexport.Iv; |
|
|
String data; |
|
|
object["path"] = "ctrl"; |
|
|
serializeJsonPretty(object, data); |
|
|
object["cmd"] = "limit_nonpersistent_absolute"; |
|
|
DPRINTLN(DBG_INFO, data); |
|
|
|
|
|
mApi.ctrlRequest(object); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
String data; |
|
|
mConfig->plugin.zexport.lastTime = millis(); // set last timestamp
|
|
|
serializeJsonPretty(object, data); |
|
|
|
|
|
DPRINTLN(DBG_INFO, data); |
|
|
|
|
|
mApi.ctrlRequest(object); |
|
|
|
|
|
} |
|
|
} |
|
|
#endif |
|
|
#endif |